@chenpu17/cc-gw 0.13.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/package.json +7 -7
- package/src/web/dist/assets/About-D2m94wu2.js +1 -0
- package/src/web/dist/assets/ApiKeys-Bt-otGF_.js +1 -0
- package/src/web/dist/assets/{ConfirmDialog-BOe5HI56.js → ConfirmDialog-CRSbmgE7.js} +1 -1
- package/src/web/dist/assets/Dashboard-81qp43jm.js +1 -0
- package/src/web/dist/assets/DialogShell-DxWKa5oR.js +1 -0
- package/src/web/dist/assets/Events-BQ4Dkqon.js +1 -0
- package/src/web/dist/assets/Help-XaAZ__Kz.js +4 -0
- package/src/web/dist/assets/Login-atwWPGzz.js +1 -0
- package/src/web/dist/assets/Logs-BYFIK_hM.js +1 -0
- package/src/web/dist/assets/PageSection-CC5EhfMe.js +1 -0
- package/src/web/dist/assets/PageState-XybOeENt.js +1 -0
- package/src/web/dist/assets/PageToolbar-CnLp4aWt.js +1 -0
- package/src/web/dist/assets/ProvidersPage-CFCY2xSG.js +1 -0
- package/src/web/dist/assets/RoutingPage-35o5ZSMg.js +1 -0
- package/src/web/dist/assets/Settings-DC1TPeS9.js +1 -0
- package/src/web/dist/assets/Setup-CnQPVK9X.js +2 -0
- package/src/web/dist/assets/TargetCombobox-DkVdA04_.js +1 -0
- package/src/web/dist/assets/apiKeys-CMk2nxB_.js +1 -0
- package/src/web/dist/assets/app-CRxPj2SJ.js +61 -0
- package/src/web/dist/assets/badge-eRkhnmCs.js +1 -0
- package/src/web/dist/assets/chartTheme-Cx-0Jiew.js +1 -0
- package/src/web/dist/assets/{charts-core-DlIzYcw_.js → charts-core-BOHudNiN.js} +1 -1
- package/src/web/dist/assets/{charts-engine-C14rMTiz.js → charts-engine-BhFpDbO0.js} +1 -1
- package/src/web/dist/assets/{charts-react-Bz6GVFr3.js → charts-react-CPWg-GRD.js} +1 -1
- package/src/web/dist/assets/clipboard-DqvcglYs.js +1 -0
- package/src/web/dist/assets/currency-Bx141-XL.js +3 -0
- package/src/web/dist/assets/disclosure-CU-KJc8C.js +1 -0
- package/src/web/dist/assets/{gateway-DxCj_uok.js → gateway-DyhqzHSh.js} +1 -1
- package/src/web/dist/assets/{global-CJOj9WGx.js → global-BLUcvOa8.js} +1 -1
- package/src/web/dist/assets/global-BQq8O0Tv.css +1 -0
- package/src/web/dist/assets/{i18n-Dp-o1LhZ.js → i18n-v60Yn7Ls.js} +1 -1
- package/src/web/dist/assets/{label-Da-JMxO2.js → label-CdbE1ezd.js} +1 -1
- package/src/web/dist/assets/{landing-BuuM1jg8.js → landing-BQdbaG8s.js} +4 -4
- package/src/web/dist/assets/modelManagement-DwdbGu0o.js +1 -0
- package/src/web/dist/assets/package-Dmrvm3RO.js +1 -0
- package/src/web/dist/assets/popover-CuM9b3U7.js +1 -0
- package/src/web/dist/assets/{query-DVc6ZTRQ.js → query-CvboQrUT.js} +1 -1
- package/src/web/dist/assets/{radix-B9EIjzyN.js → radix-d0BukFWM.js} +2 -2
- package/src/web/dist/assets/router-CqUBCAsx.js +19 -0
- package/src/web/dist/assets/segmented-control-5mZhY1KZ.js +1 -0
- package/src/web/dist/assets/shared-zfHsnBTk.js +1 -0
- package/src/web/dist/assets/switch-CZn1nypU.js +1 -0
- package/src/web/dist/assets/tabs-CrNMQMmG.js +1 -0
- package/src/web/dist/assets/{types-DYz12j32.js → types-BT3gK5lJ.js} +1 -1
- package/src/web/dist/assets/useAppMutation-B29oVzxS.js +1 -0
- package/src/web/dist/assets/{useEventStream-CQTreYBE.js → useEventStream-DN2DYBVS.js} +1 -1
- package/src/web/dist/assets/useProviderForm-DIuM3Z2u.js +1 -0
- package/src/web/dist/assets/vendor-JUtelXU0.js +445 -0
- package/src/web/dist/index.html +28 -9
- package/src/web/dist/landing.html +7 -7
- package/src/web/dist/assets/About-BJbSQIDc.js +0 -1
- package/src/web/dist/assets/ApiKeys-C8I9ti-a.js +0 -1
- package/src/web/dist/assets/Dashboard-C7n9KzBy.js +0 -1
- package/src/web/dist/assets/DialogShell-BbpG8sot.js +0 -1
- package/src/web/dist/assets/Events-BGfmA69d.js +0 -1
- package/src/web/dist/assets/Help-DUrs56_n.js +0 -4
- package/src/web/dist/assets/Login-Dxeq-BfV.js +0 -1
- package/src/web/dist/assets/Logs-VRdCNMkl.js +0 -1
- package/src/web/dist/assets/PageSection-Bv6dZZwN.js +0 -1
- package/src/web/dist/assets/PageState-U6DpaNu4.js +0 -1
- package/src/web/dist/assets/PageToolbar-BnDacS2l.js +0 -1
- package/src/web/dist/assets/ProvidersWorkbench-DOGrU9Xl.js +0 -1
- package/src/web/dist/assets/Settings-CGxWfI_h.js +0 -1
- package/src/web/dist/assets/Setup-yKUdrXJQ.js +0 -2
- package/src/web/dist/assets/apiKeys-B-WRyKci.js +0 -1
- package/src/web/dist/assets/app-BnQl39hq.js +0 -61
- package/src/web/dist/assets/badge-RZTsODn-.js +0 -1
- package/src/web/dist/assets/card-DhuLMeO9.js +0 -1
- package/src/web/dist/assets/clipboard-BnAnBk_-.js +0 -1
- package/src/web/dist/assets/disclosure-CJdf1-ap.js +0 -1
- package/src/web/dist/assets/global-CWlBZlIY.css +0 -1
- package/src/web/dist/assets/metric-card-B_6litu2.js +0 -1
- package/src/web/dist/assets/package-CKkVmaOi.js +0 -1
- package/src/web/dist/assets/popover-JpUYyIhi.js +0 -1
- package/src/web/dist/assets/router-CUBM_FND.js +0 -19
- package/src/web/dist/assets/segmented-control-D80bc13p.js +0 -1
- package/src/web/dist/assets/select-BTwqvh0l.js +0 -1
- package/src/web/dist/assets/shared-DHBfRHZV.js +0 -1
- package/src/web/dist/assets/switch-CeKtgMDT.js +0 -1
- package/src/web/dist/assets/table-rPjqxS-f.js +0 -1
- package/src/web/dist/assets/tabs-DYNHHISl.js +0 -1
- package/src/web/dist/assets/useAppMutation-Cix9n50u.js +0 -1
- package/src/web/dist/assets/useProviderForm-CsPV2Cqr.js +0 -1
- package/src/web/dist/assets/utils-HY2ZFw0f.js +0 -3
- package/src/web/dist/assets/vendor-D2wC0h2o.js +0 -409
package/README.md
CHANGED
|
@@ -72,6 +72,7 @@ Web console: http://127.0.0.1:4100/ui
|
|
|
72
72
|
- npm 安装默认分发预编译原生二进制,普通用户不需要本机 Rust 环境
|
|
73
73
|
- Web 控制台、CLI 命令习惯、配置文件路径与 SQLite 数据格式继续兼容
|
|
74
74
|
- 聚合模型:一个虚拟模型名挂多个后端(可跨供应商、跨模型名),按优先级自动降级,配额用完不再手动切流量
|
|
75
|
+
- 统一货币计费:内置常见模型价格表、可按模型覆盖,成本按展示货币实时铺满仪表盘 / 日志 / 维度统计,改价即全量重算
|
|
75
76
|
|
|
76
77
|
## 控制台预览
|
|
77
78
|
|
|
@@ -134,6 +135,7 @@ http://127.0.0.1:4100/ui
|
|
|
134
135
|
- 已实现 Anthropic / OpenAI Chat / OpenAI Responses 的代理与流式转换
|
|
135
136
|
- 已实现 API Key、日志、事件、统计、路由预设、自定义端点和 SQLite 兼容迁移
|
|
136
137
|
- 已实现聚合模型(虚拟供应商 + 成员链串行优先级降级、冷却自动恢复与后端健康观测),详见 [`docs/aggregate-models.md`](docs/aggregate-models.md)
|
|
138
|
+
- 已实现统一货币计费(内置价格表 + 用户覆盖 + 汇率换算,查询期实时计价不落库),详见 [`docs/billing.md`](docs/billing.md)
|
|
137
139
|
|
|
138
140
|
## 本地开发
|
|
139
141
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenpu17/cc-gw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Local-first AI gateway for personal developers and small software teams, with web console and CLI daemon.",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"README.md"
|
|
35
35
|
],
|
|
36
36
|
"optionalDependencies": {
|
|
37
|
-
"@chenpu17/cc-gw-darwin-arm64": "0.
|
|
38
|
-
"@chenpu17/cc-gw-linux-
|
|
39
|
-
"@chenpu17/cc-gw-win32-x64": "0.
|
|
40
|
-
"@chenpu17/cc-gw-linux-
|
|
37
|
+
"@chenpu17/cc-gw-darwin-arm64": "0.17.0",
|
|
38
|
+
"@chenpu17/cc-gw-linux-x64": "0.17.0",
|
|
39
|
+
"@chenpu17/cc-gw-win32-x64": "0.17.0",
|
|
40
|
+
"@chenpu17/cc-gw-linux-arm64": "0.17.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"colorette": "^2.0.20",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"pack:dry-run": "pnpm run build:package && node scripts/pack-root-package.mjs",
|
|
66
66
|
"publish:packed": "node scripts/publish-artifacts.mjs",
|
|
67
67
|
"test:e2e:web": "pnpm build && playwright test",
|
|
68
|
-
"test:e2e:web:core": "pnpm build && playwright test tests/playwright/aggregate-models.spec.ts tests/playwright/landing.spec.ts tests/playwright/pages.spec.ts tests/playwright/auth.spec.ts tests/playwright/logs.spec.ts tests/playwright/dashboard.spec.ts tests/playwright/events.spec.ts tests/playwright/model-management.spec.ts tests/playwright/settings.spec.ts tests/playwright/api-keys.spec.ts tests/playwright/provider-rpm.spec.ts --reporter=line",
|
|
68
|
+
"test:e2e:web:core": "pnpm build && playwright test tests/playwright/aggregate-models.spec.ts tests/playwright/landing.spec.ts tests/playwright/pages.spec.ts tests/playwright/theme-families.spec.ts tests/playwright/auth.spec.ts tests/playwright/logs.spec.ts tests/playwright/dashboard.spec.ts tests/playwright/events.spec.ts tests/playwright/model-management.spec.ts tests/playwright/settings.spec.ts tests/playwright/billing.spec.ts tests/playwright/api-keys.spec.ts tests/playwright/provider-rpm.spec.ts tests/playwright/provider-endpoints-keys.spec.ts tests/playwright/absolute-url.spec.ts tests/playwright/stream-usage.spec.ts tests/playwright/setup-wizard.spec.ts --reporter=line",
|
|
69
69
|
"test:e2e:web:visual": "pnpm build && playwright test tests/playwright/visual.spec.ts tests/playwright/visual.overlays.spec.ts tests/playwright/visual.data.spec.ts --reporter=line",
|
|
70
70
|
"test:e2e:web:hardening": "pnpm build && playwright test tests/playwright/hardening.spec.ts --reporter=line",
|
|
71
|
-
"test:e2e:web:update-snapshots": "pnpm build && playwright test tests/playwright/visual.spec.ts tests/playwright/visual.overlays.spec.ts tests/playwright/visual.data.spec.ts --update-snapshots --reporter=line",
|
|
71
|
+
"test:e2e:web:update-snapshots": "pnpm build && playwright test tests/playwright/visual.spec.ts tests/playwright/visual.overlays.spec.ts tests/playwright/visual.data.spec.ts --update-snapshots=all --reporter=line",
|
|
72
72
|
"typecheck": "pnpm --filter @cc-gw/cli exec tsc --noEmit && pnpm --filter @cc-gw/web exec tsc --noEmit"
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as n,j as t,b6 as C,b7 as v,aB as S,a0 as E}from"./vendor-JUtelXU0.js";import{P}from"./PageToolbar-CnLp4aWt.js";import{P as l}from"./PageSection-CC5EhfMe.js";import{P as A,a as j}from"./PageState-XybOeENt.js";import{u as V}from"./useAppMutation-B29oVzxS.js";import{u as L,b as q,B as c,C as k,c as y,q as B,r as F}from"./app-CRxPj2SJ.js";import{p as M}from"./package-Dmrvm3RO.js";import{u as z}from"./i18n-v60Yn7Ls.js";import"./global-BLUcvOa8.js";import"./router-CqUBCAsx.js";import"./query-CvboQrUT.js";import"./radix-d0BukFWM.js";function X(){var p,b,x,h,g;const{t:e}=z(),{pushToast:r}=L(),[o,w]=n.useState(null),a=q(B.status.gateway(),{url:"/api/status",method:"GET"},{staleTime:6e4});n.useEffect(()=>{a.isError&&a.error&&r({title:e("about.toast.statusError.title"),description:a.error.message,variant:"error"})},[r,a.error,a.isError,e]);const i=V({mutationFn:async()=>F({url:"/api/version/check",method:"GET"}),successToast:s=>s.updateAvailable?{title:e("about.toast.updateAvailable.title",{version:s.latestVersion}),description:e("about.toast.updateAvailable.description",{packageName:s.packageName})}:{title:e("about.toast.upToDate.title",{version:s.currentVersion}),description:e("about.toast.upToDate.description")},errorToast:s=>({title:e("about.toast.updateError.title"),description:s.message}),onSuccess:async s=>{w(s)}}),u=M.version,d="2026-10-22T06:18:05.343Z",T=n.useMemo(()=>{var s,f;return[{label:e("about.app.labels.name"),value:t.jsx("span",{className:"font-mono",children:"cc-gw"})},{label:e("about.app.labels.version"),value:t.jsxs("span",{"data-visual-volatile":"true",className:"font-mono text-foreground",children:["v",u]})},{label:e("about.app.labels.buildTime"),value:t.jsx("span",{"data-visual-volatile":"true",children:d}),hint:e("about.app.hint.buildTime")},{label:e("about.app.labels.runtime"),value:t.jsx("span",{className:"font-mono",children:((s=a.data)==null?void 0:s.runtime)??"rust"})},{label:e("about.app.labels.backendVersion"),value:t.jsx("span",{"data-visual-volatile":"true",className:"font-mono",children:((f=a.data)==null?void 0:f.backendVersion)??"-"})}]},[u,d,(p=a.data)==null?void 0:p.backendVersion,(b=a.data)==null?void 0:b.runtime,e]),m=n.useMemo(()=>{var s;return a.data?[{label:e("about.status.labels.providers"),value:a.data.providers.toLocaleString()},{label:e("about.status.labels.active"),value:(a.data.activeRequests??0).toLocaleString(),hint:e("about.status.hint.active")},{label:e("about.status.labels.platform"),value:a.data.platform??"-"},{label:e("about.status.labels.pid"),value:t.jsx("span",{"data-visual-volatile":"true",children:((s=a.data.pid)==null?void 0:s.toLocaleString())??"-"})}]:[]},[a.data,e]);return t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsx(P,{actions:t.jsxs(c,{onClick:()=>i.mutate(),disabled:i.isPending,size:"sm",children:[t.jsx(C,{className:`mr-2 h-4 w-4${i.isPending?" animate-spin":""}`,"aria-hidden":"true"}),i.isPending?e("about.support.actions.checkingUpdates"):e("about.support.actions.checkUpdates")]})}),t.jsx(k,{className:"overflow-hidden",children:t.jsxs(y,{className:"space-y-4 p-5",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:e("about.gateway.address")}),t.jsxs("p",{"data-visual-volatile":"true",className:"metric-number mt-1 truncate text-4xl font-semibold tracking-tight text-foreground",children:["http://",((x=a.data)==null?void 0:x.host)??"127.0.0.1",":",((h=a.data)==null?void 0:h.port)??"-"]})]}),o?t.jsxs("div",{className:"rounded-lg bg-secondary px-4 py-3 text-sm text-muted-foreground",children:[t.jsx("p",{className:"font-medium text-foreground",children:o.updateAvailable?e("about.update.available",{version:o.latestVersion}):e("about.update.current",{version:o.currentVersion})}),t.jsxs("p",{className:"mt-1",children:[e("about.update.channel",{channel:o.channel}),o.publishedAt?` · ${new Date(o.publishedAt).toLocaleString()}`:""]})]}):null]})}),t.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[t.jsx(l,{title:e("about.app.title"),description:e("about.app.subtitle"),children:t.jsx(N,{items:T})}),t.jsx(l,{title:e("about.status.title"),description:e("about.status.subtitle"),actions:t.jsxs(c,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),disabled:a.isFetching,children:[t.jsx(S,{className:D(a.isFetching),"aria-hidden":"true"}),a.isFetching?e("common.actions.refreshing"):e("common.actions.refresh")]}),children:a.isLoading?t.jsx(A,{compact:!0,label:e("about.status.loading")}):a.isError?t.jsx(j,{compact:!0,tone:"danger",icon:t.jsx(v,{className:"h-5 w-5","aria-hidden":"true"}),title:e("common.status.error"),description:((g=a.error)==null?void 0:g.message)??e("common.unknownError"),action:t.jsx(c,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:e("common.actions.refresh")})}):m.length>0?t.jsx(N,{items:m}):t.jsx(j,{compact:!0,tone:"primary",icon:t.jsx(v,{className:"h-5 w-5","aria-hidden":"true"}),title:e("about.status.empty"),description:e("common.actions.refresh")})})]}),t.jsx(l,{title:e("about.support.title"),description:t.jsxs("span",{className:"space-y-1",children:[t.jsx("span",{className:"block text-sm font-medium text-foreground",children:e("about.support.subtitle")}),t.jsx("span",{children:e("about.support.description")})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[t.jsxs("div",{className:"flex items-start gap-4 rounded-lg bg-secondary p-4",children:[t.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-background text-foreground",children:t.jsx(E,{className:"h-5 w-5","aria-hidden":"true"})}),t.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:e("about.support.tip")})]}),t.jsx("code",{className:"inline-flex self-start rounded-lg bg-secondary px-3 py-2 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})]})}function N({items:e}){return e.length===0?null:t.jsx("dl",{className:"grid gap-3 sm:grid-cols-2",children:e.map(r=>t.jsx(k,{className:"rounded-xl border border-border bg-secondary shadow-none",children:t.jsxs(y,{className:"p-4",children:[t.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:r.label}),t.jsx("dd",{className:"metric-number mt-2 text-sm font-semibold text-foreground",children:r.value}),r.hint?t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r.hint}):null]})},r.label))})}function D(e){return`mr-2 h-4 w-4${e?" animate-spin":""}`}export{X as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as p,j as e,a4 as xs,av as ie,Z as De,b0 as B,aU as ne,aD as us,b1 as fe,b2 as ms,aV as Te,a_ as ke,aY as hs}from"./vendor-JUtelXU0.js";import{a as ae,P as gs}from"./PageState-XybOeENt.js";import{P as ys}from"./PageToolbar-CnLp4aWt.js";import{B as m,C as _,c as Ae,u as js,a as O,b as Z,s as R,q as K}from"./app-CRxPj2SJ.js";import{T as bs,a as vs,b as Ne,c as we}from"./tabs-CrNMQMmG.js";import{C as Ks}from"./ConfirmDialog-CRSbmgE7.js";import{D as le,A as re,a as ce,b as oe,c as Me,d as de,e as pe}from"./DialogShell-DxWKa5oR.js";import{L as V,I as S}from"./label-CdbE1ezd.js";import{c as fs}from"./global-BLUcvOa8.js";import{E as We,R as ze,u as Ns}from"./shared-zfHsnBTk.js";import{u as f}from"./i18n-v60Yn7Ls.js";import{L as ws}from"./router-CqUBCAsx.js";import{M as J,T as Cs,a as Es,b as Ce,c as z,d as Ds,e as q,E as Ts,u as ks}from"./chartTheme-Cx-0Jiew.js";import{P as qe}from"./PageSection-CC5EhfMe.js";import{B as A}from"./badge-eRkhnmCs.js";import{S as te}from"./segmented-control-5mZhY1KZ.js";import{e as As}from"./charts-core-BOHudNiN.js";import{u as U}from"./useAppMutation-B29oVzxS.js";import{a as F}from"./apiKeys-CMk2nxB_.js";import{c as Ms}from"./clipboard-DqvcglYs.js";import"./query-CvboQrUT.js";import"./radix-d0BukFWM.js";import"./charts-react-CPWg-GRD.js";import"./charts-engine-BhFpDbO0.js";const Fe=p.forwardRef(({className:a,...s},o)=>e.jsx("textarea",{className:fs("flex min-h-[80px] w-full rounded-xl border border-border bg-card px-3 py-2.5 text-sm text-foreground ring-offset-background placeholder:text-muted-foreground/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:o,...s}));Fe.displayName="Textarea";function Ws({availableEndpoints:a,isOpen:s,keyDescription:o,keyName:n,maxConcurrency:r,onDescriptionChange:x,onEndpointsChange:b,onKeyNameChange:j,onMaxConcurrencyChange:u,onOpenChange:d,onSubmit:g,selectedEndpoints:i}){const{t:l}=f();return e.jsx(le,{open:s,onOpenChange:d,children:e.jsxs(re,{className:"max-w-2xl",children:[e.jsxs(ce,{children:[e.jsx(oe,{children:l("apiKeys.createNew")}),e.jsx(Me,{children:l("apiKeys.createDescription")})]}),e.jsxs(de,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-xs text-muted-foreground",children:l("apiKeys.selectEndpoints")}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-3 text-xs text-foreground",children:[e.jsx("p",{className:"font-semibold",children:"Restricted"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Select explicit endpoints before saving."})]}),e.jsxs("div",{className:"rounded-lg border border-warning/30 bg-warning-bg px-3 py-3 text-xs text-warning",children:[e.jsx("p",{className:"font-semibold",children:"Unrestricted"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Leave endpoint selection empty for broad access."})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-3 text-xs text-destructive",children:[e.jsx("p",{className:"font-semibold",children:"Wildcard"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Special-case key with the highest blast radius."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(V,{htmlFor:"keyName",children:[l("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(S,{id:"keyName",value:n,onChange:h=>j(h.target.value),placeholder:l("apiKeys.keyNamePlaceholder"),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),g())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"keyDescription",children:l("apiKeys.descriptionLabel")}),e.jsx(Fe,{id:"keyDescription",value:o,onChange:h=>x(h.target.value),placeholder:l("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{children:l("apiKeys.allowedEndpoints")}),e.jsx(We,{available:a,selected:i,onChange:b,hint:l("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"maxConcurrency",children:l("apiKeys.maxConcurrency")}),e.jsx(S,{id:"maxConcurrency",type:"number",min:"0",value:r,onChange:h=>u(h.target.value),placeholder:l("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(pe,{children:[e.jsx(m,{variant:"outline",onClick:()=>d(!1),children:l("common.actions.cancel")}),e.jsx(m,{onClick:g,children:l("apiKeys.createAction")})]})]})})}function zs({createdKey:a,onClose:s,onCopy:o}){const{t:n}=f();return e.jsx(le,{open:!!a,onOpenChange:r=>{r||s()},children:e.jsxs(re,{className:"max-w-xl",children:[e.jsx(ce,{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-lg bg-success-bg text-success",children:e.jsx(xs,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(oe,{children:n("apiKeys.keyCreated")})]})}),e.jsxs(de,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-warning",children:n("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 font-mono text-sm",children:a==null?void 0:a.key}),a!=null&&a.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:a.description}):null]}),e.jsxs(pe,{children:[e.jsxs(m,{onClick:()=>o((a==null?void 0:a.key)??""),children:[e.jsx(ie,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),n("common.actions.copy")]}),e.jsx(m,{variant:"outline",onClick:s,children:n("common.actions.close")})]})]})})}function qs({apiKey:a,availableEndpoints:s,maxConcurrency:o,onClose:n,onEndpointsChange:r,onMaxConcurrencyChange:x,onSave:b,selectedEndpoints:j}){const{t:u}=f();return e.jsx(le,{open:!!a,onOpenChange:d=>{d||n()},children:e.jsxs(re,{className:"max-w-2xl",children:[e.jsxs(ce,{children:[e.jsx(oe,{children:u("apiKeys.editEndpoints")}),e.jsx(Me,{children:a==null?void 0:a.name})]}),e.jsxs(de,{className:"space-y-4",children:[!(a!=null&&a.isWildcard)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border border-warning/30 bg-warning-bg px-4 py-3 text-xs text-warning",children:u("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(We,{available:s,selected:j,onChange:r,hint:u("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"editMaxConcurrency",children:u("apiKeys.maxConcurrency")}),e.jsx(S,{id:"editMaxConcurrency",type:"number",min:"0",value:o,onChange:d=>x(d.target.value),placeholder:u("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(pe,{children:[e.jsx(m,{variant:"outline",onClick:n,children:u("common.actions.cancel")}),e.jsx(m,{onClick:b,children:u("common.save")})]})]})})}function Fs({deleteTarget:a,isDeleting:s,onConfirm:o,onOpenChange:n}){const{t:r}=f();return e.jsx(Ks,{open:!!a,onOpenChange:n,title:r("apiKeys.deleteDialogTitle"),description:r("apiKeys.confirmDelete"),confirmLabel:a&&s===a.id?r("common.actions.loading"):r("apiKeys.actions.delete"),cancelLabel:r("common.actions.cancel"),loading:a?s===a.id:!1,onConfirm:o,children:a?e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 font-mono text-xs text-foreground",children:a.name}):null})}function Ls({onDismiss:a}){const{t:s}=f();return e.jsxs(_,{className:"relative p-3 sm:p-3.5",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"max-w-md space-y-1 pr-8",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-primary/75",children:"Recommended"}),e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:s("apiKeys.quickStart.title")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:s("apiKeys.quickStart.description")})]}),e.jsx("div",{className:"-mx-1 overflow-x-auto pb-1 lg:mx-0 lg:overflow-visible lg:pb-0",children:e.jsxs("div",{className:"flex gap-2 px-1 md:grid md:grid-cols-3 md:px-0 lg:max-w-3xl",children:[e.jsx(ee,{icon:e.jsx(De,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.create.title"),description:s("apiKeys.quickStart.create.description")}),e.jsx(ee,{icon:e.jsx(B,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.restrict.title"),description:s("apiKeys.quickStart.restrict.description")}),e.jsx(ee,{icon:e.jsx(ne,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.wildcard.title"),description:s("apiKeys.quickStart.wildcard.description")})]})})]}),a?e.jsx(m,{variant:"ghost",size:"icon",className:"absolute right-1.5 top-1.5 h-7 w-7 text-muted-foreground hover:bg-secondary hover:text-foreground",onClick:a,"aria-label":s("common.actions.close"),children:e.jsx(us,{className:"h-4 w-4","aria-hidden":"true"})}):null]})}function Os({activeKeysValue:a,enabledKeysValue:s,loading:o,onRangeChange:n,rangeDays:r,requestsChartOption:x,totalKeysValue:b,tokensChartOption:j,usageLength:u}){const{t:d}=f();return e.jsx(qe,{title:d("apiKeys.analytics.title"),description:d("apiKeys.analytics.description",{days:r}),actions:e.jsx(te,{className:"w-full overflow-x-auto sm:w-auto",value:r,onChange:n,options:ze.map(g=>({value:g.value,label:d(g.labelKey)}))}),children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(J,{label:d("apiKeys.analytics.cards.total"),value:b,size:"sm"}),e.jsx(J,{label:d("apiKeys.analytics.cards.enabled"),value:s,size:"sm"}),e.jsx(J,{label:d("apiKeys.analytics.cards.active",{days:r}),value:a,size:"sm"})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(Ee,{title:d("apiKeys.analytics.charts.requests"),loading:o,empty:u===0,emptyText:d("apiKeys.analytics.empty"),option:x}),e.jsx(Ee,{title:d("apiKeys.analytics.charts.tokens"),loading:o,empty:u===0,emptyText:d("apiKeys.analytics.empty"),option:j})]})]})})}function Rs({filteredKeys:a,formatDate:s,hasWildcard:o,isDeleting:n,isRevealing:r,keys:x,onCopy:b,onDelete:j,onEditEndpoints:u,onFilterChange:d,onHide:g,onReveal:i,onStatusFilterChange:l,onToggleEnabled:h,revealedKeys:C,search:D,statusFilter:E,viewMode:N,onViewModeChange:M,onCreateKey:v}){const{t:y}=f();return e.jsx(qe,{title:y("apiKeys.list.title"),description:o?y("apiKeys.wildcardHint"):void 0,actions:e.jsxs("div",{className:"flex w-full flex-wrap items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[e.jsx(te,{value:N,onChange:M,options:[{value:"cards",label:y("apiKeys.views.cards"),icon:e.jsx(fe,{className:"h-3.5 w-3.5","aria-hidden":"true"})},{value:"compact",label:y("apiKeys.views.compact"),icon:e.jsx(ms,{className:"h-3.5 w-3.5","aria-hidden":"true"})}]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.jsx(A,{variant:"outline",children:y("apiKeys.list.count",{shown:a.length,total:x.length})})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 rounded-xl bg-secondary p-4 sm:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx(S,{value:D,onChange:w=>d(w.target.value),placeholder:y("apiKeys.filters.searchPlaceholder")}),e.jsx(te,{value:E,onChange:l,className:"min-w-max overflow-x-auto bg-background sm:justify-self-end",options:[{value:"all",label:y("apiKeys.filters.all")},{value:"enabled",label:y("apiKeys.filters.enabled")},{value:"disabled",label:y("apiKeys.filters.disabled")}]})]}),x.length===0?e.jsx(ae,{compact:!0,tone:"primary",className:"rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(De,{className:"h-5 w-5","aria-hidden":"true"}),title:y("apiKeys.list.emptyTitle"),description:y("apiKeys.list.empty"),action:e.jsx(m,{variant:"outline",size:"sm",onClick:v,children:y("apiKeys.createNew")})}):a.length===0?e.jsx(ae,{compact:!0,tone:"primary",className:"rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(fe,{className:"h-5 w-5","aria-hidden":"true"}),title:y("apiKeys.list.emptyFilteredTitle"),description:y("apiKeys.list.emptyFiltered"),action:e.jsx(m,{variant:"outline",size:"sm",onClick:()=>{d(""),l("all")},children:y("common.actions.reset")})}):N==="compact"?e.jsx(Ps,{filteredKeys:a,formatDate:s,isDeleting:n,isRevealing:r,onCopy:b,onDelete:j,onEditEndpoints:u,onHide:g,onReveal:i,onToggleEnabled:h,revealedKeys:C}):e.jsx("div",{className:"grid gap-4",children:a.map(w=>e.jsx(Vs,{formatDate:s,isDeleting:n===w.id,isRevealing:r===w.id,keySummary:w,onCopy:b,onDelete:j,onEditEndpoints:u,onHide:g,onReveal:i,onToggleEnabled:h,revealedValue:C.get(w.id)},w.id))})]})})}function Ps({filteredKeys:a,formatDate:s,isDeleting:o,isRevealing:n,onCopy:r,onDelete:x,onEditEndpoints:b,onHide:j,onReveal:u,onToggleEnabled:d,revealedKeys:g}){const{t:i}=f();return e.jsx(_,{variant:"solid",className:"overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Cs,{className:"min-w-[980px]",children:[e.jsx(Es,{children:e.jsxs(Ce,{className:"bg-secondary/45 hover:bg-secondary/45",children:[e.jsx(z,{children:i("apiKeys.table.name")}),e.jsx(z,{children:i("apiKeys.table.access")}),e.jsx(z,{className:"text-right",children:i("apiKeys.requestCount")}),e.jsx(z,{className:"text-right",children:i("apiKeys.totalTokens")}),e.jsx(z,{className:"text-right",children:i("apiKeys.maxConcurrency")}),e.jsx(z,{children:i("apiKeys.lastUsed")}),e.jsx(z,{className:"w-[132px] text-right",children:i("apiKeys.table.actions")})]})}),e.jsx(Ds,{children:a.map(l=>{var E,N,M;const h=g.get(l.id),C=(l.totalInputTokens+l.totalOutputTokens).toLocaleString(),D=l.isWildcard?i("apiKeys.wildcard"):(((E=l.allowedEndpoints)==null?void 0:E.length)??0)>0?(N=l.allowedEndpoints)==null?void 0:N.join(", "):i("apiKeys.allEndpoints");return e.jsxs(Ce,{children:[e.jsx(q,{className:"py-3",children:e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-foreground",children:l.name}),l.isWildcard?e.jsx(A,{variant:"secondary",className:"text-[11px]",children:i("apiKeys.wildcard")}):null,e.jsx(A,{variant:l.enabled?"default":"outline",className:"text-[11px]",children:l.enabled?i("apiKeys.status.enabled"):i("apiKeys.status.disabled")})]}),l.isWildcard?null:e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("code",{className:"max-w-[220px] truncate rounded-md bg-secondary px-2 py-1 font-mono text-xs",children:h??l.maskedKey??"********"}),h?e.jsxs(e.Fragment,{children:[e.jsx(m,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>r(h),"aria-label":i("common.actions.copy"),children:e.jsx(ie,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(m,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>j(l.id),"aria-label":i("apiKeys.actions.hide"),children:e.jsx(ne,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):e.jsx(m,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>u(l.id),disabled:n===l.id,"aria-label":i("apiKeys.actions.reveal"),children:n===l.id?e.jsx("div",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})}),e.jsx(q,{className:"py-3",children:e.jsxs("div",{className:"max-w-[180px]",children:[e.jsx("div",{className:"truncate text-sm text-foreground",title:D,children:D}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:l.isWildcard?i("apiKeys.table.accessWildcard"):(((M=l.allowedEndpoints)==null?void 0:M.length)??0)>0?i("apiKeys.endpointRestricted"):i("apiKeys.table.accessOpen")})]})}),e.jsx(q,{className:"py-3 text-right font-medium",children:l.requestCount.toLocaleString()}),e.jsx(q,{className:"py-3 text-right font-medium",children:C}),e.jsx(q,{className:"py-3 text-right font-medium",children:l.maxConcurrency?String(l.maxConcurrency):"—"}),e.jsxs(q,{className:"py-3",children:[e.jsx("div",{"data-visual-volatile":"true",className:"text-sm font-medium text-foreground",children:s(l.lastUsedAt)}),e.jsx("div",{"data-visual-volatile":"true",className:"mt-1 text-xs text-muted-foreground",children:i("apiKeys.createdValue",{date:s(l.createdAt)})})]}),e.jsx(q,{className:"py-3",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(m,{variant:"outline",size:"icon",onClick:()=>b(l),className:"h-8 w-8","aria-label":l.isWildcard?i("apiKeys.maxConcurrency"):i("apiKeys.editEndpoints"),title:l.isWildcard?i("apiKeys.maxConcurrency"):i("apiKeys.editEndpoints"),children:e.jsx(B,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(m,{variant:"outline",size:"sm","data-testid":"api-key-toggle",onClick:()=>d(l.id,l.enabled),className:"h-8 px-2.5 text-xs",children:l.enabled?i("apiKeys.actions.disable"):i("apiKeys.actions.enable")}),l.isWildcard?null:e.jsx(m,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>x(l),disabled:o===l.id,"aria-label":i("apiKeys.actions.delete"),children:e.jsx(ke,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})})]},l.id)})})]})})})}function ee({description:a,icon:s,title:o}){return e.jsxs("div",{className:"w-[220px] shrink-0 rounded-xl border border-border bg-card p-3 md:w-auto",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-secondary text-foreground sm:h-8 sm:w-8 sm:rounded-lg",children:s}),e.jsx("p",{className:"mt-2 text-[12px] font-semibold leading-5 text-foreground sm:mt-2.5 sm:text-[13px]",children:o}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-4.5 text-muted-foreground sm:text-xs sm:leading-5",children:a})]})}function Vs({formatDate:a,isDeleting:s,isRevealing:o,keySummary:n,onCopy:r,onDelete:x,onEditEndpoints:b,onHide:j,onReveal:u,onToggleEnabled:d,revealedValue:g}){var h,C,D;const{t:i}=f(),l=(n.totalInputTokens+n.totalOutputTokens).toLocaleString();return e.jsx(_,{"data-testid":"api-key-card",className:"overflow-hidden",children:e.jsx(Ae,{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:n.name}),n.isWildcard?e.jsx(A,{variant:"secondary",children:i("apiKeys.wildcard")}):null,e.jsx(A,{variant:n.enabled?"default":"outline",children:n.enabled?i("apiKeys.status.enabled"):i("apiKeys.status.disabled")}),n.isWildcard?null:e.jsx(A,{variant:"outline",className:"text-xs",children:(((h=n.allowedEndpoints)==null?void 0:h.length)??0)>0?i("apiKeys.endpointRestricted"):i("apiKeys.allEndpoints")}),!n.isWildcard&&n.allowedEndpoints&&n.allowedEndpoints.length>0?n.allowedEndpoints.map(E=>e.jsx(A,{variant:"outline",className:"text-xs",children:E},E)):n.isWildcard?null:e.jsx(A,{variant:"secondary",className:"text-xs opacity-60",children:i("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx(se,{label:i("apiKeys.requestCount"),value:n.requestCount.toLocaleString()}),e.jsx(se,{label:i("apiKeys.totalTokens"),value:l}),e.jsx(se,{label:i("apiKeys.maxConcurrency"),value:n.maxConcurrency?String(n.maxConcurrency):i("apiKeys.maxConcurrencyPlaceholder")})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("code",{className:"block max-w-full break-all rounded-lg bg-secondary px-3 py-1.5 font-mono text-sm",children:n.isWildcard?i("apiKeys.wildcard"):g??n.maskedKey??"********"}),n.isWildcard?null:e.jsx("div",{className:"flex items-center gap-1 self-start",children:g?e.jsxs(e.Fragment,{children:[e.jsx(m,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>r(g),"aria-label":i("common.actions.copy"),title:i("common.actions.copy"),children:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(m,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(n.id),"aria-label":i("apiKeys.actions.hide"),title:i("apiKeys.actions.hide"),children:e.jsx(ne,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(m,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>u(n.id),disabled:o,"aria-label":i("apiKeys.actions.reveal"),title:i("apiKeys.actions.reveal"),children:o?e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Te,{className:"h-4 w-4","aria-hidden":"true"})})})]}),n.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:i("apiKeys.wildcardHint")}):n.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:n.description}):null,n.isWildcard?null:e.jsx("div",{className:"rounded-lg bg-secondary px-3 py-2 text-xs text-muted-foreground",children:(((C=n.allowedEndpoints)==null?void 0:C.length)??0)>0?`${i("apiKeys.allowedEndpoints")}: ${(D=n.allowedEndpoints)==null?void 0:D.join(", ")}`:i("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:i("apiKeys.created")}),e.jsx("p",{"data-visual-volatile":"true",className:"font-medium",children:a(n.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:i("apiKeys.lastUsed")}),e.jsx("p",{"data-visual-volatile":"true",className:"font-medium",children:a(n.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:flex lg:flex-wrap lg:justify-end",children:[e.jsxs(m,{variant:"outline",size:"sm",onClick:()=>b(n),className:"w-full lg:w-auto",children:[e.jsx(B,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),n.isWildcard?i("apiKeys.maxConcurrency"):i("apiKeys.editEndpoints")]}),e.jsx(m,{variant:"outline",size:"sm","data-testid":"api-key-toggle",onClick:()=>d(n.id,n.enabled),className:"w-full lg:w-auto",children:n.enabled?i("apiKeys.actions.disable"):i("apiKeys.actions.enable")}),n.isWildcard?null:e.jsx(m,{variant:"ghost",size:"icon",className:"h-9 w-full text-destructive hover:bg-destructive/10 hover:text-destructive sm:w-9",onClick:()=>x(n),disabled:s,"aria-label":i("apiKeys.actions.delete"),children:e.jsx(ke,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})})}function se({label:a,value:s}){return e.jsxs("div",{className:"rounded-lg bg-secondary px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:s})]})}function Ee({empty:a,emptyText:s,loading:o,option:n,title:r}){const{t:x}=f();return e.jsx(_,{children:e.jsxs(Ae,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:r}),o?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:x("common.loadingShort")})}):a?e.jsx(ae,{compact:!0,className:"min-h-[280px] rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(B,{className:"h-5 w-5","aria-hidden":"true"}),title:s,description:x("apiKeys.analytics.emptyHint"),action:e.jsx(m,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(ws,{to:"/logs",children:x("apiKeys.analytics.actions.logs")})})}):e.jsx(Ts,{echarts:As,option:n,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}function Is(){const{t:a}=f(),{pushToast:s}=js(),o=ks(),[n,r]=p.useState(!1),[x,b]=p.useState(""),[j,u]=p.useState(""),[d,g]=p.useState([]),[i,l]=p.useState(""),[h,C]=p.useState(null),[D,E]=p.useState(null),[N,M]=p.useState(null),[v,y]=O(R.apiKeys.rangeDays,7,{serialize:t=>String(t),deserialize:t=>{const c=Number(t);return ze.some(T=>T.value===c)?c:7}}),[w,xe]=p.useState(new Map),[Le,ue]=p.useState(null),[P,G]=p.useState(null),[I,me]=p.useState([]),[$,he]=p.useState(""),[X,Oe]=O(R.apiKeys.search,""),[Q,Re]=O(R.apiKeys.statusFilter,"all",{serialize:t=>t,deserialize:t=>t==="enabled"||t==="disabled"?t:"all"}),[Pe,Ve]=O(R.apiKeys.viewMode,()=>typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?"cards":"compact",{serialize:t=>t,deserialize:t=>t==="cards"?"cards":"compact"}),[Ie,Qe]=O(R.apiKeys.activeTab,"inventory",{serialize:t=>t,deserialize:t=>t==="analytics"?"analytics":"inventory"}),[He,Ue]=O(R.apiKeys.quickStartDismissed,!1),Se=Ns(),ge=Z(K.apiKeys.all(),F.listRequest()),Be=Z(K.apiKeys.overview(v),F.overviewRequest(v)),ye=Z(K.apiKeys.usage(v),F.usageRequest(v)),je=U({mutationFn:F.create,invalidateKeys:[K.apiKeys.all(),K.apiKeys.overview(v),K.apiKeys.usage(v)],successToast:()=>({title:a("apiKeys.toast.keyCreated")}),errorToast:t=>({title:a("apiKeys.toast.createFailure",{message:t.message})})}),H=U({mutationFn:({id:t,...c})=>F.update(t,c),invalidateKeys:[K.apiKeys.all(),K.apiKeys.overview(v),K.apiKeys.usage(v)],successToast:()=>({title:a("apiKeys.toast.keyUpdated")}),errorToast:t=>({title:a("apiKeys.toast.updateFailure",{message:t.message})})}),be=U({mutationFn:({id:t})=>F.delete(t),invalidateKeys:[K.apiKeys.all(),K.apiKeys.overview(v),K.apiKeys.usage(v)],successToast:()=>({title:a("apiKeys.toast.keyDeleted")}),errorToast:t=>({title:a("apiKeys.toast.deleteFailure",{message:t.message})})}),ve=U({mutationFn:({id:t})=>F.reveal(t),errorToast:t=>({title:a("apiKeys.toast.revealFailure"),description:t.message})}),W=ge.data??[],L=Be.data,k=ye.data??[],_e=W.some(t=>t.isWildcard),Ge=W.filter(t=>t.isWildcard).length,$e=W.filter(t=>{var c;return!t.isWildcard&&(((c=t.allowedEndpoints)==null?void 0:c.length)??0)>0}).length,Xe=W.filter(t=>{var c;return!t.isWildcard&&(((c=t.allowedEndpoints)==null?void 0:c.length)??0)===0}).length,Ye=L?L.totalKeys.toLocaleString():"-",Ze=L?L.enabledKeys.toLocaleString():"-",Je=L?L.activeKeys.toLocaleString():"-",es=p.useMemo(()=>W.filter(t=>{if(!(Q==="all"||(Q==="enabled"?t.enabled:!t.enabled)))return!1;const T=X.trim().toLowerCase();return T?[t.name,t.description??"",t.maskedKey??"",...t.allowedEndpoints??[]].join(" ").toLowerCase().includes(T):!0}),[W,X,Q]),ss=p.useMemo(()=>{const t=k.map(c=>c.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:t,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.requestsSeries"),type:"bar",data:k.map(c=>c.requests),itemStyle:{color:o.palette[0]}}]}},[a,k,o]),as=p.useMemo(()=>{const t=k.map(c=>c.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[a("apiKeys.analytics.tokens.input"),a("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:t,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:o.palette[0]},data:k.map(c=>c.inputTokens)},{name:a("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:o.palette[2]},data:k.map(c=>c.outputTokens)}]}},[a,k,o]),Ke=p.useCallback(()=>{b(""),u(""),g([]),l("")},[]),Y=p.useCallback(t=>{r(t),t||Ke()},[Ke]),ts=p.useCallback(async()=>{if(!x.trim()){s({title:a("apiKeys.errors.nameRequired"),variant:"error"});return}const t=i.trim();if(t&&(!Number.isInteger(Number(t))||Number(t)<0)){s({title:a("apiKeys.errors.maxConcurrencyInvalid"),variant:"error"});return}try{const c=await je.mutateAsync({name:x.trim(),description:j.trim()||void 0,allowedEndpoints:d.length>0?d:void 0,maxConcurrency:Number(t)>0?Number(t):null});C(c),Y(!1)}catch{}},[je,Y,j,d,i,x,s,a]),is=p.useCallback(async(t,c)=>{try{await H.mutateAsync({id:t,enabled:!c})}catch{}},[H]),ns=p.useCallback(async()=>{if(N){E(N.id);try{await be.mutateAsync({id:N.id}),M(null)}catch{}finally{E(null)}}},[N,be]),ls=p.useCallback(async t=>{if(!w.has(t)){ue(t);try{const c=await ve.mutateAsync({id:t});xe(T=>new Map(T).set(t,c.key))}catch{}finally{ue(null)}}},[ve,w]),rs=p.useCallback(t=>{xe(c=>{const T=new Map(c);return T.delete(t),T})},[]),cs=p.useCallback(async t=>{try{await Ms(t),s({title:a("apiKeys.toast.keyCopied"),variant:"success"})}catch(c){s({title:a("apiKeys.toast.copyFailure"),description:c instanceof Error?c.message:a("common.unknownError"),variant:"error"})}},[s,a]),os=p.useCallback(t=>{G(t),me(t.allowedEndpoints??[]),he(t.maxConcurrency?String(t.maxConcurrency):"")},[]),ds=p.useCallback(async()=>{if(!P)return;const t=$.trim();if(t&&(!Number.isInteger(Number(t))||Number(t)<0)){s({title:a("apiKeys.errors.maxConcurrencyInvalid"),variant:"error"});return}try{await H.mutateAsync({id:P.id,...P.isWildcard?{}:{allowedEndpoints:I.length>0?I:null},maxConcurrency:Number(t)>0?Number(t):null}),G(null)}catch{}},[P,I,$,s,a,H]),ps=p.useCallback(t=>t?new Date(t).toLocaleString():a("common.noData"),[a]);return{activeKeysValue:Je,activeTab:Ie,availableEndpoints:Se,deleteTarget:N,editEndpointsKey:P,editEndpointsSelection:I,editMaxConcurrency:$,enabledKeysValue:Ze,filteredKeys:es,formatDate:ps,handleCopyKey:cs,handleCreateDialogChange:Y,handleCreateKey:ts,handleDeleteKey:ns,handleHideKey:rs,handleOpenEditEndpoints:os,handleRevealKey:ls,handleSaveEndpoints:ds,handleToggleEnabled:is,hasWildcard:_e,isCreateDialogOpen:n,isDeleting:D,isRevealing:Le,keys:W,keysQuery:ge,newKeyDescription:j,newKeyEndpoints:d,newKeyMaxConcurrency:i,newKeyName:x,newlyCreatedKey:h,quickStartDismissed:He,rangeDays:v,requestsChartOption:ss,restrictedCount:$e,revealedKeys:w,search:X,setQuickStartDismissed:Ue,setActiveTab:Qe,setDeleteTarget:M,setEditEndpointsKey:G,setEditEndpointsSelection:me,setEditMaxConcurrency:he,setNewKeyDescription:u,setNewKeyEndpoints:g,setNewKeyMaxConcurrency:l,setNewKeyName:b,setNewlyCreatedKey:C,setRangeDays:y,setSearch:Oe,setStatusFilter:Re,statusFilter:Q,tokensChartOption:as,totalKeysValue:Ye,unrestrictedCount:Xe,usage:k,usageQuery:ye,viewMode:Pe,wildcardCount:Ge,setViewMode:Ve}}function xa(){const{t:a}=f(),s=Is();if(s.keysQuery.isLoading)return e.jsx(gs,{label:a("common.loading")});const n=s.keys.filter(r=>!r.isWildcard).length===0&&!s.quickStartDismissed;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ys,{status:e.jsxs("span",{className:"text-xs text-muted-foreground",children:[a("apiKeys.summary.wildcard",{count:s.wildcardCount})," / ",a("apiKeys.summary.restricted",{count:s.restrictedCount})," / ",a("apiKeys.summary.unrestricted",{count:s.unrestrictedCount})]}),actions:e.jsxs(m,{size:"sm",onClick:()=>s.handleCreateDialogChange(!0),children:[e.jsx(hs,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("apiKeys.createNew")]})}),n?e.jsx(Ls,{onDismiss:()=>s.setQuickStartDismissed(!0)}):null,e.jsxs(bs,{value:s.activeTab,onValueChange:r=>s.setActiveTab(r),children:[e.jsxs(vs,{children:[e.jsx(Ne,{value:"inventory",children:a("apiKeys.tabs.inventory")}),e.jsx(Ne,{value:"analytics",children:a("apiKeys.tabs.analytics")})]}),e.jsx(we,{value:"inventory",className:"mt-4",children:e.jsx(Rs,{filteredKeys:s.filteredKeys,formatDate:s.formatDate,hasWildcard:s.hasWildcard,isDeleting:s.isDeleting,isRevealing:s.isRevealing,keys:s.keys,onCopy:r=>void s.handleCopyKey(r),onDelete:s.setDeleteTarget,onEditEndpoints:s.handleOpenEditEndpoints,onFilterChange:s.setSearch,onHide:s.handleHideKey,onReveal:r=>void s.handleRevealKey(r),onStatusFilterChange:s.setStatusFilter,onToggleEnabled:(r,x)=>void s.handleToggleEnabled(r,x),revealedKeys:s.revealedKeys,search:s.search,statusFilter:s.statusFilter,viewMode:s.viewMode,onViewModeChange:s.setViewMode,onCreateKey:()=>s.handleCreateDialogChange(!0)})}),e.jsx(we,{value:"analytics",className:"mt-4",children:e.jsx(Os,{activeKeysValue:s.activeKeysValue,enabledKeysValue:s.enabledKeysValue,loading:s.usageQuery.isLoading,onRangeChange:s.setRangeDays,rangeDays:s.rangeDays,requestsChartOption:s.requestsChartOption,totalKeysValue:s.totalKeysValue,tokensChartOption:s.tokensChartOption,usageLength:s.usage.length})})]}),e.jsx(Ws,{availableEndpoints:s.availableEndpoints,isOpen:s.isCreateDialogOpen,keyDescription:s.newKeyDescription,keyName:s.newKeyName,maxConcurrency:s.newKeyMaxConcurrency,onDescriptionChange:s.setNewKeyDescription,onEndpointsChange:s.setNewKeyEndpoints,onKeyNameChange:s.setNewKeyName,onMaxConcurrencyChange:s.setNewKeyMaxConcurrency,onOpenChange:s.handleCreateDialogChange,onSubmit:()=>void s.handleCreateKey(),selectedEndpoints:s.newKeyEndpoints}),e.jsx(zs,{createdKey:s.newlyCreatedKey,onClose:()=>s.setNewlyCreatedKey(null),onCopy:r=>void s.handleCopyKey(r)}),e.jsx(qs,{apiKey:s.editEndpointsKey,availableEndpoints:s.availableEndpoints,maxConcurrency:s.editMaxConcurrency,onClose:()=>s.setEditEndpointsKey(null),onEndpointsChange:s.setEditEndpointsSelection,onMaxConcurrencyChange:s.setEditMaxConcurrency,onSave:()=>void s.handleSaveEndpoints(),selectedEndpoints:s.editEndpointsSelection}),e.jsx(Fs,{deleteTarget:s.deleteTarget,isDeleting:s.isDeleting,onConfirm:()=>void s.handleDeleteKey(),onOpenChange:r=>{!r&&s.isDeleting===null&&s.setDeleteTarget(null)}})]})}export{xa as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./vendor-
|
|
1
|
+
import{j as s}from"./vendor-JUtelXU0.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-DxWKa5oR.js";import{B as o}from"./app-CRxPj2SJ.js";function C({open:r,onOpenChange:a,title:t,description:i,confirmLabel:n,cancelLabel:d,onConfirm:c,loading:e=!1,confirmVariant:x="destructive",children:l}){return s.jsx(m,{open:r,onOpenChange:a,children:s.jsxs(p,{className:"max-w-md",children:[s.jsxs(j,{children:[s.jsx(u,{children:t}),i?s.jsx(D,{children:i}):null]}),s.jsx(f,{className:"space-y-4",children:l?s.jsx("div",{className:"text-sm text-muted-foreground",children:l}):null}),s.jsxs(g,{children:[s.jsx(o,{variant:"outline",onClick:()=>a(!1),disabled:e,children:d}),s.jsx(o,{variant:x,onClick:()=>void c(),disabled:e,children:n})]})]})})}export{C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as N,j as e,ay as Ue,az as ye,Y as Ne,U as $,aA as We,an as Ge,aB as Qe}from"./vendor-JUtelXU0.js";import{P as Ye}from"./PageToolbar-CnLp4aWt.js";import{P as H,a as A}from"./PageState-XybOeENt.js";import{u as Je,a as G,b as z,q as P,s as Q,C as Se,c as Te,B as q}from"./app-CRxPj2SJ.js";import{D as Le,S as Xe,a as Ze,b as es,c as ss,d as _}from"./disclosure-CU-KJc8C.js";import{c as ts}from"./global-BLUcvOa8.js";import{L as I}from"./router-CqUBCAsx.js";import{u as as,M as v,T as ee,a as se,b as O,c as p,d as te,e as b,E as Ce}from"./chartTheme-Cx-0Jiew.js";import{P as U}from"./PageSection-CC5EhfMe.js";import{S as ns,C as rs,T as os,f as X,g as be}from"./currency-Bx141-XL.js";import{B as R}from"./badge-eRkhnmCs.js";import{S as Re}from"./segmented-control-5mZhY1KZ.js";import{u as is}from"./useEventStream-DN2DYBVS.js";import{a as ge}from"./apiKeys-CMk2nxB_.js";import{g as ls}from"./gateway-DyhqzHSh.js";import{T as fe,L as ds,f as cs,a as F,b as je,c as ve}from"./types-BT3gK5lJ.js";import{u as g}from"./i18n-v60Yn7Ls.js";import{e as we}from"./charts-core-BOHudNiN.js";import"./query-CvboQrUT.js";import"./radix-d0BukFWM.js";import"./charts-react-CPWg-GRD.js";import"./charts-engine-BhFpDbO0.js";const us={dimensionRequest(a,t,s,n){return{url:`/api/stats/${a}`,method:"GET",params:{days:t,limit:s,...n?{endpoint:n}:{}}}}},ms=4,K=7,Y=10;function hs(a){var s;if(!a)return 0;let t=Object.keys(a.modelRoutes??{}).length;for(const n of Object.values(a.endpointRouting??{}))t+=Object.keys((n==null?void 0:n.modelRoutes)??{}).length;for(const n of a.customEndpoints??[])t+=Object.keys(((s=n.routing)==null?void 0:s.modelRoutes)??{}).length;return t}function xs(){var le,de,ce,ue,me,he,xe,pe;const{t:a}=g(),{pushToast:t}=Je(),s=as(),[n,r]=G(Q.dashboard.endpointFilter,"all"),i=n==="all"?void 0:n,d=z(P.dashboard.summary(n),{url:"/api/dashboard/summary",method:"GET",params:i?{endpoint:i}:void 0},{refetchInterval:ds}),h=z(P.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:fe}),[o,x]=G(Q.dashboard.usageDimension,"providers"),S=z(o==="apiKeys"?P.apiKeys.usage(K,n):P.stats.usageDimension(o,K,Y,n),o==="apiKeys"?ge.usageRequest(K,Y,i):us.dimensionRequest(o,K,Y,i),{refetchInterval:fe}),E=N.useMemo(()=>{const u=S.data??[];return o!=="apiKeys"?u:u.map(m=>({key:m.apiKeyName??(m.apiKeyId!=null?`#${m.apiKeyId}`:"—"),requests:m.requests,inputTokens:m.inputTokens,outputTokens:m.outputTokens,cacheReadTokens:m.cacheReadTokens??0,cacheCreationTokens:m.cacheCreationTokens??0,avgLatencyMs:m.avgLatencyMs??0,cost:m.cost??null,unpricedRequests:m.unpricedRequests??0}))},[S.data,o]),T=is({level:"warn,error",maxEvents:20}),l=N.useRef(!1);N.useEffect(()=>{var m;const u=d.error!=null;u&&!l.current&&(l.current=!0,t({title:a("dashboard.toast.overviewError"),description:((m=d.error)==null?void 0:m.message)??"",variant:"error"})),u||(l.current=!1)},[d.error,t,a]);const w=N.useCallback(async()=>{await Promise.all([d.refetch(),h.refetch(),S.refetch()])},[d,h,S]),c=d.data,k=c==null?void 0:c.overview,L=N.useMemo(()=>(c==null?void 0:c.daily)??[],[c]),j=N.useMemo(()=>(c==null?void 0:c.modelStats)??[],[c]),D=c==null?void 0:c.status,C=c==null?void 0:c.recentThroughput,M=N.useMemo(()=>(c==null?void 0:c.clientActivity)??[],[c]),Me=c==null?void 0:c.dbInfo,ae=(c==null?void 0:c.recentRequests.items)??[],B=((D==null?void 0:D.providers)??0)>0,ne=ae.length>0,re=z(P.config.full(),ls.configRequest(),{enabled:B}),W=N.useMemo(()=>hs(re.data),[re.data])>0,oe=(((le=z(P.apiKeys.all(),ge.listRequest(),{enabled:B&&W}).data)==null?void 0:le.length)??0)>0,Ie=B&&W&&oe&&ne,ke=[B,W,oe,ne].filter(Boolean).length,qe=N.useMemo(()=>{const u=(c==null?void 0:c.recentErrors)??[],m=new Set;return[...T.events,...u].filter(y=>!(m.has(y.id)||(m.add(y.id),i&&y.endpoint!==i))).slice(0,10)},[T.events,c,i]),Ae=n==="all"?a("dashboard.filters.endpointAll"):n==="anthropic"?a("dashboard.filters.endpointAnthropic"):n==="openai"?a("dashboard.filters.endpointOpenAI"):((ue=(ce=(de=h.data)==null?void 0:de.endpoints)==null?void 0:ce.find(u=>u.id===n))==null?void 0:ue.label)||n,Ee=j.filter(u=>u.avgTtftMs!=null&&u.avgTtftMs>0).sort((u,m)=>(u.avgTtftMs??Number.POSITIVE_INFINITY)-(m.avgTtftMs??Number.POSITIVE_INFINITY))[0],De=d.isFetching||h.isFetching,Pe=d.isPending,Oe=d.data?null:((me=d.error)==null?void 0:me.message)??null,ze=d.data?((he=d.error)==null?void 0:he.message)??null:null,[ie,Ke]=G(Q.dashboard.trendMode,"traffic"),Fe=N.useMemo(()=>{const u=a("dashboard.charts.barRequests"),m=a("dashboard.charts.latencyLabel");return{...s.base,color:s.palette,tooltip:{trigger:"axis",...s.base.tooltip},legend:{data:[u,m],...s.base.legend},grid:s.base.grid,xAxis:{type:"category",data:L.map(f=>f.date.slice(5)),axisLabel:{color:s.axis},axisLine:{lineStyle:{color:s.splitLine}}},yAxis:[{type:"value",name:u,nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{lineStyle:{color:s.splitLine}}},{type:"value",name:m,nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{show:!1}}],series:[{name:u,type:"bar",data:L.map(f=>f.requestCount),itemStyle:{color:s.palette[0],borderRadius:[4,4,0,0]},barMaxWidth:24},{name:m,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:L.map(f=>Math.round(f.avgLatencyMs)),itemStyle:{color:s.palette[3]},lineStyle:{width:2}}]}},[L,s,a]),Be=N.useMemo(()=>{const u=a("dashboard.charts.barRequests"),m=a("dashboard.charts.costLabel");return{...s.base,color:s.palette,tooltip:{trigger:"axis",...s.base.tooltip},legend:{data:[u,m],...s.base.legend},grid:s.base.grid,xAxis:{type:"category",data:L.map(f=>f.date.slice(5)),axisLabel:{color:s.axis},axisLine:{lineStyle:{color:s.splitLine}}},yAxis:[{type:"value",name:u,nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{lineStyle:{color:s.splitLine}}},{type:"value",name:m,nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{show:!1}}],series:[{name:u,type:"bar",data:L.map(f=>f.requestCount),itemStyle:{color:s.palette[0],opacity:.35,borderRadius:[4,4,0,0]},barMaxWidth:24},{name:m,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:L.map(f=>f.cost),itemStyle:{color:s.palette[1]},lineStyle:{width:2}}]}},[L,s,a]),Ve=ie==="cost"?Be:Fe,V=N.useCallback((u,m,f)=>({...s.base,tooltip:{trigger:"axis",...s.base.tooltip},grid:{...s.base.grid,bottom:24},xAxis:{type:"category",data:j.map(y=>`${y.provider}/${y.model}`),axisLabel:{color:s.axis,rotate:28},axisLine:{lineStyle:{color:s.splitLine}}},yAxis:{type:"value",name:u,nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{lineStyle:{color:s.splitLine}}},series:[{name:u,type:"bar",data:j.map(m),itemStyle:{color:f,borderRadius:[4,4,0,0]},barMaxWidth:32}]}),[j,s]),_e=N.useMemo(()=>V(a("dashboard.charts.ttftAxis"),u=>u.avgTtftMs??0,s.palette[2]),[V,s,a]),$e=N.useMemo(()=>V(a("dashboard.charts.tpotAxis"),u=>u.avgTpotMs??0,s.palette[4]),[V,s,a]),He=N.useMemo(()=>{const u=a("dashboard.charts.barRequests"),m=a("dashboard.charts.lineInput"),f=a("dashboard.charts.lineOutput");return{...s.base,color:s.palette,tooltip:{trigger:"axis",...s.base.tooltip},legend:{data:[u,m,f],...s.base.legend},grid:{...s.base.grid,bottom:24},xAxis:{type:"category",data:j.map(y=>`${y.provider}/${y.model}`),axisLabel:{color:s.axis,rotate:28},axisLine:{lineStyle:{color:s.splitLine}}},yAxis:[{type:"value",name:u,nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{lineStyle:{color:s.splitLine}}},{type:"value",name:a("dashboard.charts.axisTokens"),position:"right",nameTextStyle:{color:s.axis},axisLabel:{color:s.axis},splitLine:{show:!1}}],series:[{name:u,type:"bar",data:j.map(y=>y.requests),itemStyle:{color:s.palette[0],borderRadius:[4,4,0,0]},barMaxWidth:24},{name:m,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:j.map(y=>y.inputTokens??0),itemStyle:{color:s.palette[1]},lineStyle:{width:2}},{name:f,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:j.map(y=>y.outputTokens??0),itemStyle:{color:s.palette[2]},lineStyle:{width:2}}]}},[j,s,a]);return{attentionEvents:qe,customEndpoints:((xe=h.data)==null?void 0:xe.endpoints)??[],daily:L,dbInfo:Me,clientActivity:M,endpointFilter:n,fastestTtftModel:Ee,handleRefresh:w,bootstrapError:Oe,refreshError:ze,isBootstrapping:Pe,isRefreshing:De,liveConnected:T.connected,liveFailed:T.failed,modelRequestsOption:He,models:j,overview:k,recentLogs:ae,recentThroughput:C,selectedEndpointLabel:Ae,setEndpointFilter:r,setupComplete:Ie,setupDoneCount:ke,status:D,summaryPending:d.isPending,trendMode:ie,setTrendMode:Ke,trendOption:Ve,ttftOption:_e,tpotOption:$e,usageDimension:o,usageDimensionLoading:S.isPending,usageDimensionError:((pe=S.error)==null?void 0:pe.message)??null,refetchUsageDimension:()=>void S.refetch(),usageRows:E,setUsageDimension:x}}function ps(){return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-6",children:Array.from({length:6}).map((a,t)=>e.jsx(ns,{},t))}),e.jsx(rs,{}),e.jsx("div",{className:"border border-border bg-card",children:e.jsx("table",{className:"w-full",children:e.jsx("tbody",{children:Array.from({length:5}).map((a,t)=>e.jsx(os,{columns:6},t))})})})]})}function bs({status:a,recentThroughput:t}){const{t:s}=g();return e.jsxs("div",{className:"space-y-3","data-testid":"dashboard-spotlight-grid",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm","data-testid":"dashboard-overview-panel",children:[e.jsx("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-success-bg px-1.5 py-0.5 text-[11px] font-medium text-success before:h-1.5 before:w-1.5 before:rounded-full before:bg-success before:animate-live-pulse",children:s("dashboard.status.listeningLabel")}),e.jsx("span",{"data-testid":"dashboard-runtime-address",className:"metric-number text-sm font-semibold tracking-tight text-foreground",children:e.jsxs("span",{"data-visual-volatile":"true",children:[(a==null?void 0:a.host)??"0.0.0.0",":",(a==null?void 0:a.port)??"-"]})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s("dashboard.status.providers",{value:(a==null?void 0:a.providers)??0})})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-6",children:[e.jsx(v,{size:"md",label:s("dashboard.labels.activeRequests"),value:((a==null?void 0:a.activeRequests)??0).toLocaleString(),rawValue:(a==null?void 0:a.activeRequests)??0,valueTestId:"dashboard-spotlight-value-active"}),e.jsx(v,{size:"md",label:s("dashboard.labels.requestsPerMinute"),value:((a==null?void 0:a.requestsPerMinute)??0).toLocaleString(),rawValue:(a==null?void 0:a.requestsPerMinute)??0,valueTestId:"dashboard-spotlight-value-rpm"}),e.jsx(v,{size:"md",label:s("dashboard.labels.inputTpm10m",{value:(t==null?void 0:t.windowMinutes)??10}),value:((t==null?void 0:t.inputTokensPerMinute)??0).toLocaleString(),rawValue:(t==null?void 0:t.inputTokensPerMinute)??0,valueTestId:"dashboard-spotlight-value-tpm-in"}),e.jsx(v,{size:"md",label:s("dashboard.labels.outputTpm10m",{value:(t==null?void 0:t.windowMinutes)??10}),value:((t==null?void 0:t.outputTokensPerMinute)??0).toLocaleString(),rawValue:(t==null?void 0:t.outputTokensPerMinute)??0,valueTestId:"dashboard-spotlight-value-tpm-out"}),e.jsx(v,{size:"md",label:s("dashboard.labels.uniqueClientAddressesLastHour"),value:((a==null?void 0:a.uniqueClientAddressesLastHour)??0).toLocaleString(),rawValue:(a==null?void 0:a.uniqueClientAddressesLastHour)??0}),e.jsx(v,{size:"md",label:s("dashboard.labels.cpu"),value:e.jsx("span",{"data-visual-volatile":"true",children:cs(a==null?void 0:a.cpuUsagePercent)}),valueTestId:"dashboard-spotlight-value-cpu"})]})]})}function gs(a){switch(a){case"error":return e.jsx(R,{variant:"destructive",children:"error"});case"warn":return e.jsx(R,{variant:"warning",children:"warn"});default:return e.jsx(R,{variant:"secondary",children:"info"})}}function Z(a,t){const s=new URLSearchParams;a&&a!=="all"&&s.set("endpoint",a),t&&s.set("status",t);const n=s.toString();return n?`/logs?${n}`:"/logs"}function fs({overview:a,endpointFilter:t}){const{t:s}=g(),n=a==null?void 0:a.today,r=a==null?void 0:a.yesterday,i=(n==null?void 0:n.requests)??0,d=(n==null?void 0:n.inputTokens)??0,h=(n==null?void 0:n.outputTokens)??0,o=(n==null?void 0:n.cacheReadTokens)??0,x=(n==null?void 0:n.errorCount)??0,S=a==null?void 0:a.costCurrency,E=(n==null?void 0:n.unpricedRequests)??0,T=i>0?x/i*100:0,l=r&&(r.requests??0)>0?r.errorCount/r.requests*100:void 0,w=o+d,c=w>0?o/w*100:0,k=(C,M)=>M!==void 0&&M>0?((C??0)-M)/M*100:void 0,L=C=>`${C>0?"+":""}${C.toFixed(1)}%`,j=(C,M=!1)=>C!==void 0&&Math.abs(C)>=.05?{value:C,invertColor:M,format:L}:void 0,D=i>0?k(T,l):void 0;return e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-6","data-testid":"dashboard-today-grid",children:[e.jsx(v,{size:"md",label:s("dashboard.cards.todayRequests"),value:i.toLocaleString(),rawValue:i,delta:j(k(i,r==null?void 0:r.requests)),hint:r&&r.requests>0?s("dashboard.cards.yesterdayHint",{value:r.requests.toLocaleString()}):void 0,valueTestId:"dashboard-today-value-requests"}),e.jsx(v,{size:"md",label:s("dashboard.cards.todayInput"),value:d.toLocaleString(),rawValue:d,suffix:s("common.units.token"),delta:j(k(d,r==null?void 0:r.inputTokens)),valueTestId:"dashboard-today-value-input"}),e.jsx(v,{size:"md",label:s("dashboard.cards.todayOutput"),value:h.toLocaleString(),rawValue:h,suffix:s("common.units.token"),delta:j(k(h,r==null?void 0:r.outputTokens)),valueTestId:"dashboard-today-value-output"}),e.jsx(v,{size:"md",label:s("dashboard.cards.todayCacheRead"),value:o.toLocaleString(),rawValue:o,suffix:s("common.units.token"),hint:w>0?s("dashboard.cards.cacheHitHint",{value:c.toFixed(1)}):void 0,valueTestId:"dashboard-today-value-cache-read"}),e.jsx(v,{size:"md",label:s("dashboard.cards.todayCost"),value:X(n==null?void 0:n.cost,S),delta:j(k((n==null?void 0:n.cost)??void 0,(r==null?void 0:r.cost)??void 0)),hint:E>0?s("dashboard.cards.unpricedHint",{count:E}):void 0,valueTestId:"dashboard-today-value-cost"}),e.jsx(v,{size:"md",label:s("dashboard.cards.todayErrorRate"),value:T>0?e.jsxs("span",{className:"text-destructive",children:[T.toFixed(1),"%"]}):`${T.toFixed(1)}%`,delta:j(D,!0),hint:x>0?e.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1",children:[s("dashboard.cards.errorCountHint",{value:x}),e.jsx(I,{to:Z(t,"error"),className:"font-medium text-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:decoration-foreground",children:s("dashboard.cards.viewErrors")})]}):void 0,valueTestId:"dashboard-today-value-error-rate"})]})}function js({status:a,entries:t}){const{t:s}=g();if(t.length===0)return null;const n=r=>r==="unknown"?s("dashboard.usage.clientKinds.unknown"):s(`dashboard.usage.clientKinds.${r}`,{defaultValue:r});return e.jsx("div",{"data-testid":"dashboard-client-activity",className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:t.map(r=>{var d;const i=((d=a==null?void 0:a.activeByClientKind)==null?void 0:d[r.clientKind])??0;return e.jsxs("div",{"data-testid":"dashboard-client-activity-card",className:"rounded-lg border border-border bg-card px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:n(r.clientKind)}),e.jsx("div",{className:"font-mono text-[10.5px] text-muted-foreground",children:r.clientKind})]}),e.jsx("span",{className:i>0?"inline-flex shrink-0 items-center gap-1 rounded-md bg-success-bg px-1.5 py-0.5 text-[11px] font-medium text-success before:h-1.5 before:w-1.5 before:rounded-full before:bg-success before:animate-live-pulse":"shrink-0 rounded-md bg-secondary px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground",children:s("dashboard.clientActivity.active",{value:i})})]}),e.jsxs("dl",{className:"mt-2.5 grid grid-cols-2 gap-x-3 gap-y-1 text-[11px] tabular-nums text-muted-foreground",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("dt",{children:s("dashboard.clientActivity.requests")}),e.jsx("dd",{className:"font-medium text-foreground",children:r.requests.toLocaleString()})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("dt",{children:s("dashboard.clientActivity.sessions")}),e.jsx("dd",{className:"font-medium text-foreground",children:r.sessions.toLocaleString()})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("dt",{children:s("dashboard.clientActivity.input")}),e.jsx("dd",{children:r.inputTokens.toLocaleString()})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("dt",{children:s("dashboard.clientActivity.output")}),e.jsx("dd",{children:r.outputTokens.toLocaleString()})]})]})]},r.clientKind)})})}function vs({connected:a,failed:t,events:s}){const{t:n}=g();return s.length===0?null:e.jsx(U,{title:n("dashboard.attention.title"),description:n("dashboard.attention.subtitle"),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:t?"inline-flex items-center gap-1 text-[11px] font-medium text-destructive before:h-1.5 before:w-1.5 before:rounded-full before:bg-destructive":a?"inline-flex items-center gap-1 text-[11px] font-medium text-success before:h-1.5 before:w-1.5 before:rounded-full before:bg-success before:animate-live-pulse":"inline-flex items-center gap-1 text-[11px] font-medium text-warning before:h-1.5 before:w-1.5 before:rounded-full before:bg-warning",children:n(t?"dashboard.attention.failed":a?"dashboard.attention.live":"dashboard.attention.reconnecting")}),e.jsx(q,{asChild:!0,variant:"ghost",size:"sm",className:"h-7",children:e.jsx(I,{to:"/events",children:n("dashboard.attention.viewAll")})})]}),children:e.jsx("ul",{className:"divide-y divide-border",children:e.jsx(Ue,{initial:!1,children:s.map(r=>e.jsxs(ye.li,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:.18},className:"flex items-start gap-3 py-2.5 first:pt-0 last:pb-0",children:[e.jsx("div",{className:"pt-0.5",children:gs(r.level)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:r.title??r.type}),r.message?e.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:r.message}):null]}),e.jsx("span",{"data-visual-volatile":"true",className:"shrink-0 pt-0.5 text-[11px] tabular-nums text-muted-foreground/70",children:new Date(r.createdAt).toLocaleTimeString()})]},r.id))})})})}function ys({connected:a,failed:t}){const{t:s}=g();return e.jsxs(ye.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},transition:{duration:.18},"data-testid":"dashboard-all-clear",className:"flex h-8 flex-wrap items-center gap-x-2 gap-y-1 bg-success-bg px-3 text-xs text-success",children:[e.jsx(Ge,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium",children:s("dashboard.attention.allClear")}),e.jsx("span",{className:t?"ml-auto inline-flex items-center gap-1.5 text-[11px] font-medium text-destructive before:h-1.5 before:w-1.5 before:rounded-full before:bg-destructive":a?"ml-auto inline-flex items-center gap-1.5 text-[11px] font-medium before:h-1.5 before:w-1.5 before:rounded-full before:bg-success before:animate-live-pulse":"ml-auto inline-flex items-center gap-1.5 text-[11px] font-medium text-warning before:h-1.5 before:w-1.5 before:rounded-full before:bg-warning",children:s(t?"dashboard.attention.failed":a?"dashboard.attention.live":"dashboard.attention.reconnecting")}),e.jsx(I,{to:"/events",className:"shrink-0 underline-offset-2 hover:underline",children:s("dashboard.attention.viewAll")})]})}function Ns({empty:a,loading:t,option:s,mode:n,onModeChange:r}){const{t:i}=g();return e.jsx(ks,{title:i("dashboard.charts.trendTitle"),description:i(n==="cost"?"dashboard.charts.trendCostDesc":"dashboard.charts.trendDesc"),loading:t,option:s,empty:a,emptyText:i("dashboard.charts.empty"),actions:e.jsx(Re,{value:n,onChange:r,"aria-label":i("dashboard.charts.trendModeLabel"),options:[{value:"traffic",label:e.jsx("span",{"data-testid":"dashboard-trend-mode-traffic",children:i("dashboard.charts.trendModeTraffic")})},{value:"cost",label:e.jsx("span",{"data-testid":"dashboard-trend-mode-cost",children:i("dashboard.charts.trendModeCost")})}]})})}function Ss({daily:a,models:t}){const{t:s}=g();if(a.length===0&&t.length===0)return null;const n=a.reduce((o,x)=>o+x.requestCount,0),r=a.length>0?a.reduce((o,x)=>x.requestCount>o.requestCount?x:o,a[0]):null,i=t.length>0?t.reduce((o,x)=>x.requests>o.requests?x:o,t[0]):null,d=t.filter(o=>o.avgTtftMs!=null&&o.avgTtftMs>0).sort((o,x)=>(o.avgTtftMs??Number.POSITIVE_INFINITY)-(x.avgTtftMs??Number.POSITIVE_INFINITY))[0],h=[{label:s("dashboard.insights.totalRequests"),value:n>0?n.toLocaleString():"—",hint:n>0?s("dashboard.insights.totalRequestsHint"):void 0},{label:s("dashboard.insights.busiestDay"),value:r?r.date.slice(5):"—",hint:r?s("dashboard.insights.busiestDayHint",{value:r.requestCount.toLocaleString()}):void 0},{label:s("dashboard.insights.topModel"),value:i?i.model:"—",hint:i?s("dashboard.insights.topModelHint",{value:i.requests.toLocaleString()}):void 0},{label:s("dashboard.insights.fastestTtft"),value:d?d.model:"—",hint:d?s("dashboard.insights.fastestTtftHint",{value:Math.round(d.avgTtftMs??0)}):void 0}];return e.jsx("div",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","data-testid":"dashboard-insights-grid",children:h.map(o=>e.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-[0.06em] text-muted-foreground",children:o.label}),e.jsx("div",{className:"metric-number mt-2 truncate text-base font-bold tracking-tight text-foreground",children:o.value}),o.hint?e.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:o.hint}):null]},o.label))})}function Ts({dimension:a,onDimensionChange:t,rows:s,loading:n,error:r,onRetry:i,customEndpoints:d,costCurrency:h}){const{t:o}=g(),x=[{value:"providers",label:o("dashboard.usage.tabs.providers")},{value:"endpoints",label:o("dashboard.usage.tabs.endpoints")},{value:"clients",label:o("dashboard.usage.tabs.clients")},{value:"apiKeys",label:o("dashboard.usage.tabs.apiKeys")}],S=l=>{var w;return l==="anthropic"?o("dashboard.filters.endpointAnthropic"):l==="openai"?o("dashboard.filters.endpointOpenAI"):((w=d.find(c=>c.id===l))==null?void 0:w.label)||l},E=l=>l==="unknown"?o("dashboard.usage.clientKinds.unknown"):o(`dashboard.usage.clientKinds.${l}`,{defaultValue:l}),T=l=>{switch(a){case"endpoints":return e.jsx(R,{variant:"outline",className:"text-[11px]",children:S(l.key)});case"clients":return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:E(l.key)}),e.jsx("span",{className:"font-mono text-[11px] text-muted-foreground",children:l.key})]});case"apiKeys":return e.jsx("span",{className:"font-medium",children:l.key});default:return e.jsx("span",{className:"font-mono text-[13px] font-medium",children:l.key})}};return e.jsx(U,{title:o("dashboard.usage.title"),description:o("dashboard.usage.description",{value:K}),actions:e.jsx(Re,{value:a,onChange:t,"aria-label":o("dashboard.usage.title"),options:x.map(l=>({value:l.value,label:e.jsx("span",{"data-testid":`dashboard-usage-tab-${l.value}`,children:l.label})}))}),children:n?e.jsx(H,{compact:!0,label:o("common.loadingShort")}):r&&s.length===0?e.jsx(A,{compact:!0,tone:"danger",icon:e.jsx(Ne,{className:"h-5 w-5","aria-hidden":"true"}),title:o("dashboard.usage.error"),description:r,action:i?e.jsx(q,{variant:"outline",size:"sm",onClick:i,children:o("common.actions.retry")}):void 0}):s.length===0?e.jsx(A,{inline:!0,icon:e.jsx($,{className:"h-3.5 w-3.5","aria-hidden":"true"}),title:o("dashboard.usage.empty")}):e.jsx("div",{className:"overflow-auto",children:e.jsxs(ee,{children:[e.jsx(se,{children:e.jsxs(O,{children:[e.jsx(p,{children:o("dashboard.usage.columns.dimension")}),e.jsx(p,{className:"text-right",children:o("dashboard.usage.columns.requests")}),e.jsx(p,{className:"text-right",children:o("dashboard.usage.columns.input")}),e.jsx(p,{className:"text-right",children:o("dashboard.usage.columns.output")}),e.jsx(p,{className:"text-right",children:o("dashboard.usage.columns.cacheRead")}),e.jsx(p,{className:"text-right",children:o("dashboard.usage.columns.cacheCreation")}),e.jsx(p,{className:"text-right",children:o("dashboard.usage.columns.cost")}),e.jsx(p,{className:"text-right",children:o("dashboard.usage.columns.latency")})]})}),e.jsx(te,{children:s.map(l=>e.jsxs(O,{"data-testid":"dashboard-usage-row",children:[e.jsx(b,{children:T(l)}),e.jsx(b,{className:"text-right font-medium",children:l.requests.toLocaleString()}),e.jsx(b,{className:"text-right",children:l.inputTokens.toLocaleString()}),e.jsx(b,{className:"text-right",children:l.outputTokens.toLocaleString()}),e.jsx(b,{className:"text-right",children:l.cacheReadTokens.toLocaleString()}),e.jsx(b,{className:"text-right",children:l.cacheCreationTokens.toLocaleString()}),e.jsx(b,{className:"text-right tabular-nums","data-testid":"dashboard-usage-cost",children:l.unpricedRequests>0?e.jsxs("span",{className:"inline-flex items-baseline gap-0.5",title:o("dashboard.usage.unpricedHint",{count:l.unpricedRequests}),children:[X(l.cost,h),e.jsx("span",{"aria-hidden":"true",children:"*"})]}):X(l.cost,h)}),e.jsx(b,{className:"text-right",children:e.jsx("span",{"data-visual-volatile":"true",children:F(l.avgLatencyMs,o("common.units.ms"))})})]},`${a}:${l.key}`))})]})})})}function Ls({modelRequestsOption:a,models:t,ttftOption:s,tpotOption:n}){const{t:r}=g();return e.jsxs(Le,{variant:"card",summaryClassName:"px-4 py-3",contentClassName:"border-t border-border px-4 py-4",summary:e.jsx("span",{className:"text-sm font-medium text-foreground",children:r("dashboard.sections.performance")}),children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsx(J,{title:r("dashboard.charts.modelTitle"),option:a,empty:!t.length}),e.jsx(J,{title:r("dashboard.charts.ttftTitle"),option:s,empty:!t.some(i=>i.avgTtftMs!=null&&i.avgTtftMs>0)}),e.jsx(J,{title:r("dashboard.charts.tpotTitle"),option:n,empty:!t.some(i=>i.avgTpotMs!=null&&i.avgTpotMs>0)})]}),e.jsx("div",{className:"mt-4",children:e.jsx(Ms,{models:t,embedded:!0})})]})}function Cs({dbInfo:a,dbSizeDisplay:t,memoryDisplay:s,status:n}){const{t:r}=g();return e.jsx(Le,{variant:"card",summaryClassName:"px-4 py-3",contentClassName:"border-t border-border px-4 py-4",summary:e.jsx("span",{className:"text-sm font-medium text-foreground",children:r("dashboard.cards.systemResources")}),badge:e.jsxs("span",{"data-visual-volatile":"true",className:"text-xs tabular-nums text-muted-foreground",children:[t," · ",s]}),children:e.jsxs("div",{className:"grid gap-2.5 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(v,{size:"sm",label:r("dashboard.labels.networkIngress"),value:je(n==null?void 0:n.networkIngressBytesPerSecond),valueTestId:"dashboard-spotlight-value-ingress"}),e.jsx(v,{size:"sm",label:r("dashboard.labels.networkEgress"),value:je(n==null?void 0:n.networkEgressBytesPerSecond),valueTestId:"dashboard-spotlight-value-egress"}),e.jsx(v,{size:"sm",label:r("dashboard.labels.database"),value:t,valueTestId:"dashboard-spotlight-value-database"}),e.jsx(v,{size:"sm",label:r("dashboard.labels.memory"),value:s,valueTestId:"dashboard-spotlight-value-memory"})]})})}function Rs({doneCount:a,total:t}){const{t:s}=g(),n=Math.min(100,Math.round(a/t*100));return e.jsxs("div",{"data-testid":"dashboard-setup-progress",className:"flex flex-wrap items-center gap-x-3 gap-y-2 bg-secondary/60 px-4 py-2",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:s("dashboard.setupProgress.label",{done:a,total:t})}),e.jsx("div",{className:"h-1.5 min-w-24 flex-1 overflow-hidden bg-border/60",children:e.jsx("div",{className:"h-1.5 bg-primary transition-all",style:{width:`${n}%`}})}),e.jsx(I,{to:"/setup",className:"shrink-0 text-xs font-medium text-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:decoration-foreground",children:s("dashboard.setupProgress.cta")})]})}function ws({endpointCount:a,providerCount:t}){const{t:s}=g(),n=[{title:s("dashboard.guide.step1Title"),description:t>0?s("dashboard.guide.step1DescDone",{count:t}):s("dashboard.guide.step1Desc"),href:"/providers",cta:s("dashboard.guide.step1Cta")},{title:s("dashboard.guide.step2Title"),description:a>0?s("dashboard.guide.step2DescDone",{count:a}):s("dashboard.guide.step2Desc"),href:"/routing",cta:s("dashboard.guide.step2Cta")},{title:s("dashboard.guide.step3Title"),description:s("dashboard.guide.step3Desc"),href:"/api-keys",cta:s("dashboard.guide.step3Cta")}];return e.jsx(Se,{className:"relative overflow-hidden",children:e.jsxs(Te,{className:"space-y-5 pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:s("dashboard.guide.title")}),e.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:s("dashboard.guide.subtitle")})]}),e.jsx(q,{asChild:!0,size:"sm",children:e.jsx(I,{to:"/setup",children:s("dashboard.guide.startWizard")})})]}),e.jsx("ol",{className:"grid gap-3 lg:grid-cols-3",children:n.map((r,i)=>e.jsxs("li",{className:"rounded-lg border border-border p-4",children:[e.jsx("span",{className:"metric-number text-xs font-semibold text-muted-foreground",children:String(i+1).padStart(2,"0")}),e.jsx("h4",{className:"mt-2 text-sm font-semibold text-foreground",children:r.title}),e.jsx("p",{className:"mt-1.5 text-xs leading-6 text-muted-foreground",children:r.description}),e.jsx(q,{asChild:!0,variant:"ghost",size:"sm",className:"mt-2 h-8 px-0 text-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:bg-transparent hover:decoration-foreground",children:e.jsx(I,{to:r.href,children:r.cta})})]},r.title))})]})})}function Ms({models:a,loading:t,embedded:s}){const{t:n}=g(),r=t?e.jsx(H,{compact:!0,label:n("common.loadingShort")}):a.length===0?e.jsx(A,{inline:!0,icon:e.jsx($,{className:"h-3.5 w-3.5","aria-hidden":"true"}),title:n("dashboard.modelTable.empty")}):e.jsx("div",{className:"overflow-auto",children:e.jsxs(ee,{children:[e.jsx(se,{children:e.jsxs(O,{children:[e.jsx(p,{children:n("dashboard.modelTable.columns.model")}),e.jsx(p,{className:"text-right",children:n("dashboard.modelTable.columns.requests")}),e.jsx(p,{className:"text-right",children:n("dashboard.modelTable.columns.latency")}),e.jsx(p,{className:"text-right",children:n("dashboard.modelTable.columns.ttft")}),e.jsx(p,{className:"text-right",children:n("dashboard.modelTable.columns.tpot")})]})}),e.jsx(te,{children:a.map(i=>e.jsxs(O,{children:[e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:i.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i.model})]})}),e.jsx(b,{className:"text-right font-medium",children:i.requests.toLocaleString()}),e.jsx(b,{className:"text-right",children:e.jsx("span",{"data-visual-volatile":"true",children:F(i.avgLatencyMs,n("common.units.ms"))})}),e.jsx(b,{className:"text-right",children:e.jsx("span",{"data-visual-volatile":"true",children:F(i.avgTtftMs,n("common.units.ms"))})}),e.jsx(b,{className:"text-right",children:e.jsx("span",{"data-visual-volatile":"true",children:F(i.avgTpotMs,n("common.units.msPerToken"),{maximumFractionDigits:2})})})]},`${i.provider}/${i.model}`))})]})});return s?r:e.jsx(U,{title:n("dashboard.modelTable.title"),description:n("dashboard.modelTable.description"),children:r})}function Is({records:a,loading:t,endpointFilter:s}){const{t:n}=g(),r=a.map(o=>be(o,n)),i=r.filter(o=>o.tone==="success").length,d=r.filter(o=>o.tone==="error").length,h=r.filter(o=>o.tone==="pending").length;return e.jsx(U,{title:n("dashboard.recent.title"),description:n("dashboard.recent.subtitle",{count:5}),actions:a.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{variant:"secondary",children:a.length}),e.jsxs(R,{variant:"success",children:[n("common.status.success"),": ",i]}),e.jsxs(R,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[n("common.status.error"),": ",d]}),h>0?e.jsxs(R,{variant:"warning",children:[n("common.status.pending"),": ",h]}):null,e.jsx(I,{to:Z(s),className:"ml-1 text-xs font-medium text-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:decoration-foreground",children:n("dashboard.recent.viewAll")})]}):e.jsx(I,{to:Z(s),className:"text-xs font-medium text-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:decoration-foreground",children:n("dashboard.recent.viewAll")}),children:t?e.jsx(H,{compact:!0,label:n("dashboard.recent.loading")}):a.length===0?e.jsx(A,{inline:!0,icon:e.jsx(We,{className:"h-3.5 w-3.5","aria-hidden":"true"}),title:n("dashboard.recent.empty")}):e.jsx("div",{className:"overflow-auto",children:e.jsxs(ee,{children:[e.jsx(se,{children:e.jsxs(O,{children:[e.jsx(p,{children:n("dashboard.recent.columns.time")}),e.jsx(p,{children:n("dashboard.recent.columns.endpoint")}),e.jsx(p,{children:n("dashboard.recent.columns.provider")}),e.jsx(p,{children:n("dashboard.recent.columns.route")}),e.jsx(p,{className:"text-right",children:n("dashboard.recent.columns.latency")}),e.jsx(p,{children:n("dashboard.recent.columns.status")})]})}),e.jsx(te,{children:a.map(o=>{const x=be(o,n);return e.jsxs(O,{children:[e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{"data-visual-volatile":"true",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(b,{children:e.jsx(R,{variant:"outline",className:"text-[11px]",children:o.endpoint==="anthropic"?n("logs.endpointAnthropic"):o.endpoint==="openai"?n("logs.endpointOpenAI"):o.endpoint})}),e.jsx(b,{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(b,{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??n("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(b,{className:"text-right font-medium",children:e.jsx("span",{"data-visual-volatile":"true",children:F(o.latency_ms,n("common.units.ms"))})}),e.jsx(b,{children:e.jsx(R,{variant:x.variant,className:"min-w-14 justify-center",children:x.label})})]},o.id)})})]})})})}function J({empty:a,option:t,title:s}){const{t:n}=g();return e.jsxs("div",{className:"rounded-lg border border-border p-3",children:[e.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:s}),a?e.jsx(A,{inline:!0,icon:e.jsx($,{className:"h-3.5 w-3.5","aria-hidden":"true"}),title:n("dashboard.charts.empty")}):e.jsx(Ce,{echarts:we,option:t,className:"h-[220px]",notMerge:!0,lazyUpdate:!0})]})}function ks({description:a,empty:t,emptyText:s,loading:n,option:r,title:i,actions:d}){const{t:h}=g();return e.jsx(Se,{children:e.jsxs(Te,{className:"space-y-4 pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold",children:i}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground/70",children:a})]}),d]}),n?e.jsx(H,{compact:!0,className:"min-h-[220px]",label:h("common.loadingShort")}):t?e.jsx(A,{inline:!0,icon:e.jsx($,{className:"h-3.5 w-3.5","aria-hidden":"true"}),title:s??h("dashboard.charts.empty")}):e.jsx("div",{className:"pt-2",children:e.jsx(Ce,{echarts:we,option:r,className:"h-[36vh] min-h-[260px] max-h-[400px]",notMerge:!0,lazyUpdate:!0})})]})})}function tt(){var r,i,d;const{t:a}=g(),t=xs(),s=t.dbInfo?ve(t.dbInfo.totalBytes??t.dbInfo.sizeBytes):"-",n=ve((r=t.dbInfo)==null?void 0:r.memoryRssBytes);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Ye,{actions:e.jsxs(e.Fragment,{children:[e.jsxs(Xe,{value:t.endpointFilter,onValueChange:t.setEndpointFilter,children:[e.jsx(Ze,{className:"h-8 w-[168px]",children:e.jsx(es,{})}),e.jsxs(ss,{children:[e.jsx(_,{value:"all",children:a("dashboard.filters.endpointAll")}),e.jsx(_,{value:"anthropic",children:a("dashboard.filters.endpointAnthropic")}),e.jsx(_,{value:"openai",children:a("dashboard.filters.endpointOpenAI")}),t.customEndpoints.map(h=>e.jsx(_,{value:h.id,children:h.label||h.id},h.id))]})]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>void t.handleRefresh(),disabled:t.isRefreshing,children:[e.jsx(Qe,{className:ts("mr-2 h-4 w-4",t.isRefreshing&&"animate-spin"),"aria-hidden":"true"}),t.isRefreshing?a("common.actions.refreshing"):a("common.actions.refresh")]})]})}),t.isBootstrapping?e.jsx(ps,{}):t.bootstrapError?e.jsx(A,{icon:e.jsx(Ne,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:a("common.status.error"),description:t.bootstrapError,action:e.jsx(q,{variant:"outline",onClick:()=>void t.handleRefresh(),children:a("common.actions.refresh")})}):e.jsxs(e.Fragment,{children:[t.refreshError?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border border-warning/30 bg-warning-bg px-3 py-2 text-xs text-warning",children:[e.jsx("span",{children:a("dashboard.refreshFailed",{message:t.refreshError})}),e.jsx(q,{variant:"outline",size:"sm",onClick:()=>void t.handleRefresh(),disabled:t.isRefreshing,children:a("common.actions.refresh")})]}):null,t.setupComplete?null:e.jsx(ws,{endpointCount:t.customEndpoints.length,providerCount:((i=t.status)==null?void 0:i.providers)??0}),e.jsx(bs,{status:t.status,recentThroughput:t.recentThroughput}),t.attentionEvents.length>0?e.jsx(vs,{connected:t.liveConnected,failed:t.liveFailed,events:t.attentionEvents}):null,e.jsx(fs,{overview:t.overview,endpointFilter:t.endpointFilter}),e.jsx(js,{status:t.status,entries:t.clientActivity}),t.setupComplete?null:e.jsx(Rs,{doneCount:t.setupDoneCount,total:ms}),e.jsx(Ns,{empty:!t.daily.length,loading:t.summaryPending,option:t.trendOption,mode:t.trendMode,onModeChange:t.setTrendMode}),e.jsx(Ss,{daily:t.daily,models:t.models}),e.jsx(Ts,{dimension:t.usageDimension,onDimensionChange:t.setUsageDimension,rows:t.usageRows,loading:t.usageDimensionLoading,error:t.usageDimensionError,onRetry:t.refetchUsageDimension,customEndpoints:t.customEndpoints,costCurrency:(d=t.overview)==null?void 0:d.costCurrency}),e.jsx(Ls,{modelRequestsOption:t.modelRequestsOption,models:t.models,ttftOption:t.ttftOption,tpotOption:t.tpotOption}),e.jsx(Cs,{dbInfo:t.dbInfo,dbSizeDisplay:s,memoryDisplay:n,status:t.status}),e.jsx(Is,{records:t.recentLogs,loading:t.summaryPending,endpointFilter:t.endpointFilter}),t.attentionEvents.length>0?null:e.jsx(ys,{connected:t.liveConnected,failed:t.liveFailed})]})]})}export{tt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,j as s,aD as u}from"./vendor-JUtelXU0.js";import{m as g,p as n,D as l,n as y,o as d,y as N,O as i}from"./radix-d0BukFWM.js";import{c as o}from"./global-BLUcvOa8.js";const k=g,b=y,c=r.forwardRef(({className:a,...e},t)=>s.jsx(i,{ref:t,className:o("fixed inset-0 z-50 bg-background/95 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...e}));c.displayName=i.displayName;const p=r.forwardRef(({className:a,children:e,...t},x)=>s.jsxs(b,{children:[s.jsx(c,{}),s.jsxs(d,{ref:x,className:o("fixed left-[50%] top-[50%] z-50 flex max-h-[85vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-xl border border-border bg-background/[var(--surface-alpha)] surface-blur p-6 shadow-[var(--surface-shadow-lg)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",a),...t,children:[e,s.jsxs(N,{className:"absolute right-4 top-4 rounded-md p-1.5 text-muted-foreground opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(u,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));p.displayName=d.displayName;const f=({className:a,...e})=>s.jsx("div",{className:o("flex shrink-0 flex-col space-y-1.5 text-center sm:text-left",a),...e});f.displayName="DialogHeader";const m=({className:a,...e})=>s.jsx("div",{className:o("flex shrink-0 flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...e});m.displayName="DialogFooter";const j=r.forwardRef(({className:a,...e},t)=>s.jsx(n,{ref:t,className:o("text-lg font-semibold leading-none tracking-[-0.02em]",a),...e}));j.displayName=n.displayName;const D=r.forwardRef(({className:a,...e},t)=>s.jsx(l,{ref:t,className:o("text-sm leading-6 text-muted-foreground",a),...e}));D.displayName=l.displayName;function R({children:a,className:e,...t}){return s.jsx(p,{className:o("gap-0 overflow-hidden p-0",e),...t,children:a})}function A({children:a,className:e}){return s.jsx("div",{className:o("border-b border-border bg-secondary/40 px-6 py-5",e),children:s.jsx(f,{children:a})})}function C({children:a,className:e}){return s.jsx("div",{className:o("min-h-0 overflow-y-auto px-6 py-5",e),children:a})}function z({children:a,className:e}){return s.jsx(m,{className:o("border-t border-border bg-secondary/40 px-6 py-4",e),children:a})}export{R as A,k as D,A as a,j as b,D as c,C as d,z as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as c,j as e,aG as H,a3 as J,Y as U,aH as Y,ay as _,az as W}from"./vendor-JUtelXU0.js";import{L as X}from"./router-CqUBCAsx.js";import{P as Z}from"./PageToolbar-CnLp4aWt.js";import{P as ee,a as z}from"./PageState-XybOeENt.js";import{u as se,b as F,B as x,q as D,C as te,c as ae}from"./app-CRxPj2SJ.js";import{u as re}from"./useEventStream-DN2DYBVS.js";import{c as E}from"./global-BLUcvOa8.js";import{i as ne,u as V}from"./i18n-v60Yn7Ls.js";import{B as y}from"./badge-eRkhnmCs.js";import{S as le,a as oe,b as ie,c as ce,d as B,D as de}from"./disclosure-CU-KJc8C.js";import{S as ue}from"./segmented-control-5mZhY1KZ.js";import"./query-CvboQrUT.js";import"./radix-d0BukFWM.js";function me(s){const r=Date.now()-s,l=Math.abs(r),o=60*1e3,f=60*o,d=24*f,m=new Intl.RelativeTimeFormat(ne.language||"en",{numeric:"auto"});if(l<o){const a=Math.max(Math.round(l/1e3),1);return m.format(r>=0?-a:a,"second")}if(l<f){const a=Math.round(l/o);return m.format(r>=0?-a:a,"minute")}if(l<d){const a=Math.round(l/f);return m.format(r>=0?-a:a,"hour")}const h=Math.round(l/d);return m.format(r>=0?-h:h,"day")}function xe(s){return new Date(s).toLocaleString()}const fe={info:"secondary",warn:"outline",error:"destructive"};function Ae(){var L,A,M,k,I,P,R;const{t:s}=V(),{pushToast:n}=se(),[r,l]=c.useState(null),[o,f]=c.useState(""),[d,m]=c.useState(""),h=c.useMemo(()=>({limit:50,cursor:r??void 0,level:o||void 0,type:d||void 0}),[r,o,d]),a=F(D.events.list(h),{url:"/api/events",method:"GET",params:h}),u=F(D.events.stats(),{url:"/api/events/stats",method:"GET"},{refetchInterval:15e3}),q=((L=u.data)==null?void 0:L.error)??0,G=((A=u.data)==null?void 0:A.warn)??0,K=((M=u.data)==null?void 0:M.info)??0,O=((k=u.data)==null?void 0:k.total)??0,i=re({level:o||void 0,type:d||void 0,maxEvents:50,enabled:r===null}),N=c.useRef(!1);c.useEffect(()=>{const t=a.isError;t&&a.error&&!N.current&&(N.current=!0,n({title:s("events.toast.loadFailure",{message:a.error.message}),variant:"error"})),t||(N.current=!1)},[a.error,a.isError,n,s]);const C=c.useRef(!1);c.useEffect(()=>{const t=u.isError;t&&u.error&&!C.current&&(C.current=!0,n({title:s("events.toast.statsLoadFailure",{message:u.error.message}),variant:"error"})),t||(C.current=!1)},[u.error,u.isError,n,s]);const S=()=>{l(null),f(""),m("")},v=((I=a.data)==null?void 0:I.events)??[],T=((P=a.data)==null?void 0:P.nextCursor)??null,Q=a.isLoading,b=c.useMemo(()=>{if(r!==null)return v;const t=new Set;return[...i.events,...v].filter(p=>t.has(p.id)?!1:(t.add(p.id),!0)).slice(0,50)},[r,i.events,v]),$=c.useMemo(()=>{const t=new Set;return v.forEach(p=>t.add(p.type)),i.events.forEach(p=>t.add(p.type)),Array.from(t).sort()},[v,i.events]),g=c.useMemo(()=>{const t=[];return o&&t.push(s(`events.levels.${o}`)),d&&t.push(d),t},[o,d,s]);return e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(Z,{status:r===null?e.jsxs("span",{className:E("inline-flex items-center gap-1.5 text-xs font-medium",i.connected?"text-success":i.failed?"text-destructive":"text-warning"),children:[e.jsx("span",{"aria-hidden":"true",className:E("h-1.5 w-1.5 rounded-full",i.connected?"bg-success animate-live-pulse":i.failed?"bg-destructive":"bg-warning")}),i.connected?s("events.live"):i.failed?s("events.failed"):s("events.reconnecting")]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:s("events.actions.older")}),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[!i.connected&&r===null?e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:s("common.actions.refresh")}):null,e.jsxs("div",{className:"flex items-center gap-2 border border-border bg-secondary px-2 py-1.5",children:[e.jsxs(x,{variant:"outline",size:"sm",disabled:!r,onClick:()=>l(null),children:[e.jsx(H,{className:"mr-1 h-4 w-4","aria-hidden":"true"}),s("events.actions.newest")]}),b.length>0?e.jsx("span",{className:"metric-number px-1 text-sm text-muted-foreground",children:s("events.pageCount",{count:b.length})}):null,e.jsxs(x,{variant:"outline",size:"sm",disabled:!T,onClick:()=>l(T),children:[s("events.actions.older"),e.jsx(J,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]})]})]})}),e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:flex-wrap md:items-center","data-testid":"events-filters-card",children:[e.jsx(ue,{value:o,onChange:t=>{l(null),f(t)},className:"min-w-max overflow-x-auto",options:[{value:"",label:e.jsx(w,{label:s("events.filters.allLevels"),count:O,testId:"events-stat-total"})},{value:"info",label:e.jsx(w,{label:s("events.levels.info"),count:K,testId:"events-stat-info"})},{value:"warn",label:e.jsx(w,{label:s("events.levels.warn"),count:G,testId:"events-stat-warn"})},{value:"error",label:e.jsx(w,{label:s("events.levels.error"),count:q,testId:"events-stat-error"})}],"aria-label":s("events.filters.title")}),e.jsxs(le,{value:d||"all",onValueChange:t=>{l(null),m(t==="all"?"":t)},children:[e.jsx(oe,{className:"h-8 w-full md:w-[200px]",children:e.jsx(ie,{})}),e.jsxs(ce,{children:[e.jsx(B,{value:"all",children:s("events.filters.allTypes")}),$.map(t=>e.jsx(B,{value:t,children:t},t))]})]}),g.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:g.map(t=>e.jsx(y,{variant:"secondary",children:t},t))}),e.jsx(x,{variant:"ghost",size:"sm",onClick:S,className:"h-8 px-3 text-xs",children:s("common.actions.reset")})]}):null]}),Q?e.jsx(ee,{label:s("common.loading")}):a.isError?e.jsx(z,{icon:e.jsx(U,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:s("events.toast.loadFailure",{message:((R=a.error)==null?void 0:R.message)??s("common.unknownError")}),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:s("common.actions.refresh")})}):b.length===0?e.jsx(z,{icon:e.jsx(Y,{className:"h-5 w-5","aria-hidden":"true"}),tone:"primary",title:g.length>0?s("events.empty.filteredTitle"):s("events.empty.title"),description:g.length>0?s("events.empty.filteredSubtitle"):s("events.empty.subtitle"),action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[g.length>0?e.jsx(x,{variant:"outline",size:"sm",onClick:S,children:s("common.actions.reset")}):null,e.jsx(x,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(X,{to:"/logs",children:s("events.empty.actions.logs")})})]})}):e.jsx("div",{className:"grid gap-3",children:e.jsx(_,{initial:!1,children:b.map(t=>e.jsx(W.div,{layout:!0,initial:{opacity:0,y:-12},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:.18},children:e.jsx(pe,{event:t})},t.id))})})]})}function w({label:s,count:n,testId:r}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s,e.jsx("span",{className:"tabular-nums opacity-60","data-testid":r,children:n.toLocaleString()})]})}function pe({event:s}){const{t:n}=V(),r=s.level==="error"?"border-l-error":s.level==="warn"?"border-l-warning":"border-l-success";return e.jsx(te,{className:E("overflow-hidden border-l-2 hover:bg-muted/30",r),children:e.jsxs(ae,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(y,{variant:fe[s.level]||"secondary",className:"text-[10px]",children:n(`events.levels.${s.level}`)}),e.jsxs(y,{variant:"outline",className:"text-[10px]",children:["#",s.id]}),s.mode?e.jsx(y,{variant:"secondary",className:"text-[10px]",children:s.mode}):null,s.endpoint?e.jsx(y,{variant:"outline",className:"text-[10px]",children:s.endpoint}):null]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-[-0.01em]",children:s.title||n("events.defaultTitle")}),e.jsx("p",{className:"mt-1 line-clamp-2 break-words text-sm leading-5 text-muted-foreground [overflow-wrap:anywhere]",children:s.message||n("events.defaultMessage")})]})]}),e.jsxs("div",{className:"shrink-0 space-y-0.5 text-xs text-muted-foreground lg:text-right",children:[e.jsx("p",{"data-visual-volatile":"true",children:xe(s.createdAt)}),e.jsx("p",{"data-visual-volatile":"true",children:me(s.createdAt)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm",children:[e.jsx(j,{label:"Type",value:s.type}),e.jsx(j,{label:"Source",value:s.source}),e.jsx(j,{label:"IP",value:s.ipAddress}),e.jsx(j,{label:"API Key",value:s.apiKeyName}),e.jsx(j,{label:"User Agent",value:s.userAgent})]}),s.details?e.jsx(de,{summary:n("events.details"),className:"rounded-lg bg-secondary px-3 py-2 text-sm",summaryClassName:"px-0 py-0 text-xs font-medium text-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:decoration-foreground",contentClassName:"mt-2.5",children:e.jsx("pre",{className:"overflow-x-auto rounded-lg bg-secondary p-3 text-xs leading-6",children:JSON.stringify(s.details,null,2)})}):null]})})}function j({label:s,value:n}){return n?e.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 border border-border/60 bg-secondary/55 px-2.5 py-1 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"font-medium",children:[s,":"]}),e.jsx("span",{className:"truncate text-foreground",title:n,children:n})]}):null}export{Ae as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as u,j as e}from"./vendor-JUtelXU0.js";import{P as b}from"./PageToolbar-CnLp4aWt.js";import{P as c}from"./PageSection-CC5EhfMe.js";import{c as N}from"./clipboard-DqvcglYs.js";import{c as x}from"./global-BLUcvOa8.js";import{B as y}from"./app-CRxPj2SJ.js";import{u as g}from"./i18n-v60Yn7Ls.js";import"./router-CqUBCAsx.js";import"./query-CvboQrUT.js";import"./radix-d0BukFWM.js";function E(){const{t}=g(),r=u.useMemo(()=>[{id:"tour",title:t("help.sections.consoleTour.title"),items:t("help.sections.consoleTour.items",{returnObjects:!0})},{id:"configuration",title:t("help.sections.configuration.title"),items:t("help.sections.configuration.items",{returnObjects:!0})},{id:"claude",title:t("help.sections.claudeCodeConfig.title"),items:t("help.sections.claudeCodeConfig.items",{returnObjects:!0})},{id:"codex",title:t("help.sections.codexConfig.title"),items:t("help.sections.codexConfig.items",{returnObjects:!0})},{id:"usage",title:t("help.sections.usage.title"),items:t("help.sections.usage.items",{returnObjects:!0})},{id:"tips",title:t("help.sections.tips.title"),items:t("help.sections.tips.items",{returnObjects:!0})}],[t]),i=t("help.faq.items",{returnObjects:!0}),l=u.useMemo(()=>[...r.map(o=>({id:o.id,title:o.title})),{id:"faq",title:t("help.faq.title")}],[r,t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{info:e.jsx("span",{className:"bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:t("help.meta.guides",{count:r.length})})}),e.jsxs("div",{className:"rounded-lg border border-border/60 bg-card px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:t("help.note")}),e.jsx("p",{className:"mt-1 text-xs leading-5",children:t("help.helper")})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[208px_minmax(0,1fr)] xl:items-start",children:[e.jsx("aside",{className:"hidden xl:sticky xl:top-4 xl:block",children:e.jsxs("nav",{"aria-label":t("help.meta.tocTitle"),className:"rounded-lg border border-border/60 bg-card p-3",children:[e.jsx("p",{className:"mb-2 px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:t("help.meta.tocTitle")}),e.jsx("ol",{className:"space-y-0.5 text-sm",children:l.map(o=>e.jsx("li",{children:e.jsx("a",{href:`#help-${o.id}`,className:"block truncate rounded-md px-2 py-1.5 text-muted-foreground transition hover:bg-accent hover:text-foreground",children:o.title})},o.id))})]})}),e.jsxs("div",{className:"min-w-0 space-y-5",children:[e.jsx("div",{id:"help-tour",children:e.jsx(c,{title:r[0].title,children:e.jsx(a,{items:r[0].items,compact:!0})})}),e.jsx("div",{id:"help-configuration",children:e.jsx(c,{title:r[1].title,children:e.jsx(a,{items:r[1].items})})}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsx(c,{title:r[2].title,description:t("help.meta.claudeWorkflow"),children:e.jsx(a,{items:r[2].items})})}),e.jsx("div",{id:"help-codex",children:e.jsx(c,{title:r[3].title,description:t("help.meta.codexWorkflow"),children:e.jsx(a,{items:r[3].items})})})]}),e.jsx("div",{id:"help-usage",children:e.jsx(c,{title:r[4].title,children:e.jsx(a,{items:r[4].items})})}),e.jsx("div",{id:"help-tips",children:e.jsx(c,{title:r[5].title,children:e.jsx(a,{items:r[5].items})})}),e.jsx("div",{id:"help-faq",children:e.jsx(c,{title:t("help.faq.title"),children:e.jsx(w,{items:i})})})]})]})]})}function a({items:t,compact:r=!1}){return e.jsx("ol",{className:x("flex flex-col",r?"gap-2":"gap-2.5"),children:t.map((i,l)=>e.jsxs("li",{className:x("flex gap-3 rounded-lg border border-border/50 bg-card",r?"p-3":"p-3.5"),children:[e.jsx("span",{className:x("flex shrink-0 items-center justify-center rounded-md bg-foreground text-xs font-semibold text-background",r?"h-6 w-6 text-[11px]":"h-7 w-7"),children:l+1}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-muted-foreground",children:e.jsx(f,{content:i})})]},`${l}-${i}`))})}function f({content:t}){const{t:r}=g(),i=t.split("```"),[l,o]=u.useState(null),m=async(d,s)=>{try{await N(s),o(d),window.setTimeout(()=>o(n=>n===d?null:n),1500)}catch{}};return e.jsx("div",{className:"space-y-3",children:i.map((d,s)=>{if(!d.trim())return null;if(s%2===1){const[n,...j]=d.split(`
|
|
2
|
+
`),h=j.join(`
|
|
3
|
+
`).trim();return e.jsxs("div",{className:"overflow-hidden rounded-md border border-border/55 bg-secondary",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/55 px-3 py-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n||"bash"}),e.jsx(y,{variant:"ghost",size:"sm",className:"h-6 rounded px-2 text-[11px] text-muted-foreground hover:text-foreground",onClick:()=>void m(s,h),children:r(l===s?"common.actions.copied":"common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto px-3 py-2.5 font-mono text-[12px] leading-6 text-foreground",children:e.jsx("code",{className:"block min-w-full whitespace-pre",children:h})})]},s)}return e.jsx(v,{content:d},s)})})}function v({content:t}){const r=t.split(`
|
|
4
|
+
`).map(s=>s.trimEnd()).filter(s=>s.trim().length>0);if(r.length===0)return null;const i=r.filter(s=>/^[-•*]\s+/.test(s.trim())),l=r.filter(s=>/^\d+[).]\s+/.test(s.trim())),o=r.filter(s=>!/^([-•*]|\d+[).])\s+/.test(s.trim())),m=i.map(s=>s.replace(/^[-•*]\s+/,"")),d=l.map(s=>{const n=s.trim().match(/^(\d+)[).]\s+(.*)$/);return{index:(n==null?void 0:n[1])??"",text:(n==null?void 0:n[2])??s.trim()}});return e.jsxs("div",{className:"space-y-2",children:[o.length>0?e.jsx("div",{className:"space-y-1.5",children:o.map((s,n)=>e.jsx("p",{className:"leading-6",children:p(s)},`${s}-${n}`))}):null,m.length>0?e.jsx("ul",{className:"space-y-1.5 rounded-md bg-secondary px-3 py-2",children:m.map((s,n)=>e.jsxs("li",{className:"flex gap-2 text-sm leading-6",children:[e.jsx("span",{className:"mt-2 h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground"}),e.jsx("span",{children:p(s)})]},`${s}-${n}`))}):null,d.length>0?e.jsx("ol",{className:"space-y-1.5 rounded-md bg-secondary px-3 py-2",children:d.map(s=>e.jsxs("li",{className:"flex gap-2.5 text-sm leading-6",children:[e.jsx("span",{className:"mt-0.5 flex h-5 min-w-5 items-center justify-center bg-secondary px-1.5 text-[11px] font-semibold text-foreground",children:s.index}),e.jsx("span",{children:p(s.text)})]},`${s.index}-${s.text}`))}):null]})}function p(t){return t.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).map((i,l)=>i.startsWith("`")&&i.endsWith("`")?e.jsx("code",{className:"rounded bg-secondary px-1.5 py-0.5 text-[0.95em] text-foreground",children:i.slice(1,-1)},l):i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:i.slice(2,-2)},l):e.jsx("span",{children:i},l))}function w({items:t}){return t.length===0?null:e.jsx("dl",{className:"space-y-2",children:t.map((r,i)=>e.jsxs("details",{className:"group overflow-hidden rounded-lg border border-border/50 bg-card",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-2.5 text-sm font-medium text-foreground",children:[e.jsx("span",{children:r.q}),e.jsx("span",{className:"bg-secondary px-2 py-0.5 text-[11px] text-muted-foreground transition group-open:bg-secondary group-open:text-foreground",children:i+1})]}),e.jsx("div",{className:"border-t border-border/50 px-4 py-3",children:e.jsx("dd",{className:"text-sm text-muted-foreground",children:e.jsx(f,{content:r.a})})})]},r.q))})}export{E as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,j as e,b8 as E,b9 as k}from"./vendor-JUtelXU0.js";import{p as F,C as j,c as b,L,l as S,m as P,n as T,B as A,v as B}from"./app-CRxPj2SJ.js";import{L as N,I as v}from"./label-CdbE1ezd.js";import{u as D}from"./i18n-v60Yn7Ls.js";import{a as I,b as q}from"./router-CqUBCAsx.js";import"./global-BLUcvOa8.js";import"./query-CvboQrUT.js";import"./radix-d0BukFWM.js";function z(){const{t:s}=D(),a=I(),l=q(),{authEnabled:o,isAuthenticated:u,loading:c,login:y,error:x}=F(),[n,p]=i.useState({username:"",password:""}),[g,m]=i.useState(null),[h,f]=i.useState(!1),d=i.useMemo(()=>{var r;const t=l.state;return((r=t==null?void 0:t.from)==null?void 0:r.pathname)??"/"},[l.state]);i.useEffect(()=>{if(!o&&!c){a(d,{replace:!0});return}o&&u&&!c&&a(d,{replace:!0})},[o,d,u,c,a]),i.useEffect(()=>{document.title=`${s("login.title")} · cc-gw`},[s]);const C=async t=>{if(t.preventDefault(),m(null),!n.username.trim()||!n.password){m(s("login.validation.required"));return}f(!0);try{await y(n.username.trim(),n.password),a(d,{replace:!0})}catch(r){m(r instanceof Error?r.message:s("login.validation.failed"))}finally{f(!1)}};return c?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(L,{})})})}):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-lg bg-secondary px-3 py-1 text-xs font-semibold text-foreground",children:s("login.badge")}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-foreground",children:s("login.title")}),e.jsx("p",{className:"max-w-md text-base leading-7 text-muted-foreground",children:s("login.description")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(w,{icon:e.jsx(E,{className:"h-5 w-5","aria-hidden":"true"}),title:s("login.hint"),description:s("about.support.tip")}),e.jsx(w,{icon:e.jsx(k,{className:"h-5 w-5","aria-hidden":"true"}),title:s("login.sessionProtected"),description:s("help.note")})]})]})}),e.jsxs(j,{className:"w-full",children:[e.jsxs(S,{className:"pb-4 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground",children:"GW"}),e.jsx(P,{className:"text-xl",children:s("login.title")}),e.jsx(T,{children:s("login.description")})]}),e.jsx(b,{children:e.jsxs("form",{className:"space-y-4",onSubmit:C,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(v,{id:"username",value:n.username,autoComplete:"username",autoFocus:!0,onChange:t=>p(r=>({...r,username:t.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(v,{id:"password",type:"password",value:n.password,autoComplete:"current-password",onChange:t=>p(r=>({...r,password:t.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),g||x?e.jsx("div",{role:"alert",className:"rounded-lg bg-destructive/10 px-4 py-3 text-sm text-destructive",children:g||x}):null,e.jsx(A,{type:"submit",className:"w-full",disabled:h,children:s(h?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(B,{className:"justify-center pt-2",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})]})}):null}function w({description:s,icon:a,title:l}){return e.jsxs("div",{className:"rounded-lg bg-card/[var(--surface-alpha)] surface-blur px-4 py-4 shadow-[var(--surface-shadow)]",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-secondary text-foreground",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{z as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as p,j as e,t as Is,aC as $s,au as Vs,aD as Us,av as Ye,aE as Xe,aB as Qs,aF as Hs,a3 as Ze,Y as Bs,V as Ws,aG as Gs}from"./vendor-JUtelXU0.js";import{P as Js}from"./PageToolbar-CnLp4aWt.js";import{s as K,C as es,c as ss,B as D,d as Ys,u as _e,b as re,q as se,t as Xs,a as I}from"./app-CRxPj2SJ.js";import{B as le}from"./badge-eRkhnmCs.js";import{L as X,I as ye}from"./label-CdbE1ezd.js";import{S as ts}from"./segmented-control-5mZhY1KZ.js";import{S as pe,a as xe,b as ge,c as he,d as U,D as Zs}from"./disclosure-CU-KJc8C.js";import{c as v}from"./global-BLUcvOa8.js";import{u as Q}from"./i18n-v60Yn7Ls.js";import{D as et,A as st,a as tt,b as lt,c as at,d as rt}from"./DialogShell-DxWKa5oR.js";import{P as ot,a as ne}from"./PageState-XybOeENt.js";import{T as ls,a as as,b as rs,c as os}from"./tabs-CrNMQMmG.js";import{c as nt}from"./clipboard-DqvcglYs.js";import{a as it,g as Le,b as ns,c as Z,d as Ee,e as W,f as ee,h as Ce,p as is,i as ds,j as cs,k as dt,T as ct}from"./currency-Bx141-XL.js";import{P as ut,a as mt,b as pt}from"./popover-CuM9b3U7.js";import{S as xt}from"./switch-CZn1nypU.js";import{L as us,u as gt}from"./router-CqUBCAsx.js";import{a as ht}from"./query-CvboQrUT.js";import{g as We}from"./gateway-DyhqzHSh.js";import"./radix-d0BukFWM.js";function ft({apiKeys:s,selected:l,onChange:i,disabled:a,className:o}){const{t}=Q(),d=p.useId(),[c,g]=p.useState(!1),[h,f]=p.useState(null),C=p.useRef(null),N=p.useRef(null),m=p.useRef(null),_=()=>{const y=N.current;if(!y)return;const x=y.getBoundingClientRect(),L=Math.max(x.width,256),u=window.innerWidth-12;f({left:Math.min(x.left,u-L),top:x.bottom+8,width:L})};p.useEffect(()=>{if(!c)return;const y=L=>{var F,R;const u=L.target;!((F=C.current)!=null&&F.contains(u))&&!((R=m.current)!=null&&R.contains(u))&&g(!1)},x=L=>{var u;L.key==="Escape"&&(g(!1),(u=N.current)==null||u.focus())};return window.addEventListener("mousedown",y),window.addEventListener("keydown",x),()=>{window.removeEventListener("mousedown",y),window.removeEventListener("keydown",x)}},[c]),p.useEffect(()=>{if(c)return _(),window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[c]);const r=p.useMemo(()=>{if(l.length===0)return[];const y=new Map;for(const x of s)y.set(x.id,x);return l.map(x=>{const L=y.get(x);return L?L.isWildcard?t("apiKeys.wildcard"):L.name:null}).filter(x=>!!x)},[s,l,t]),w=l.length===0?t("logs.filters.apiKeyAll"):t("logs.filters.apiKeySelected",{count:l.length}),b=y=>{l.includes(y)?i(l.filter(x=>x!==y)):i([...l,y])};return e.jsxs("div",{className:v("relative space-y-2",o),ref:C,children:[e.jsx(X,{htmlFor:d,children:t("logs.filters.apiKey")}),e.jsxs("button",{ref:N,id:d,type:"button",onClick:()=>{_(),g(y=>!y)},disabled:a||s.length===0,title:t("logs.filters.apiKeyHint"),className:v("flex h-10 w-full items-center justify-between rounded-lg border border-input bg-background px-3 text-sm ring-offset-background transition-all focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",l.length>0&&"border-foreground",c&&"ring-2 ring-ring ring-offset-2"),children:[e.jsxs("span",{className:"truncate",children:[w,r.length>0&&e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:r.join(", ")})]}),e.jsx("svg",{className:v("h-4 w-4 opacity-50 transition-transform",c&&"rotate-180"),viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 10.94l3.71-3.71a.75.75 0 111.06 1.06l-4.24 4.25a.75.75 0 01-1.06 0L5.21 8.29a.75.75 0 01.02-1.08z",clipRule:"evenodd"})})]}),c&&h&&Is.createPortal(e.jsxs("div",{ref:m,className:"fixed z-50 rounded-lg border bg-popover p-2 shadow-[var(--surface-shadow-lg)]",style:h,children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-secondary px-3 py-2 text-xs",children:[e.jsx("span",{children:w}),e.jsx("button",{type:"button",onClick:()=>i([]),disabled:l.length===0,className:"text-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:decoration-foreground disabled:opacity-40",children:t("common.actions.reset")})]}),e.jsxs("div",{className:"max-h-56 overflow-y-auto py-2",children:[s.map(y=>{const x=y.isWildcard?t("apiKeys.wildcard"):y.name,L=l.includes(y.id);return e.jsxs("label",{className:v("flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2 text-sm transition hover:bg-accent",L&&"bg-secondary text-foreground"),children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-border",checked:L,onChange:()=>b(y.id)}),e.jsx("span",{className:"truncate",children:x})]},y.id)}),s.length===0&&e.jsx("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:t("logs.filters.apiKeyAll")})]})]}),document.body)]})}const oe=[20,50,100],yt=["all","errors","today","anthropic","openai"],bt=["claude-code","codex","opencode","gemini-cli","cline","roo-code","cursor","crush","aider","kilo-code","droid","copilot","anthropic-compatible","openai-compatible"],B=["endpoint","provider","client","requestedModel","routedModel","apiKey","tokens","cost","duration","status","error"],te=["endpoint","provider","client","requestedModel","routedModel","apiKey","tokens","cost","duration","status","error"];function jt(){return typeof window>"u"?"comfortable":window.localStorage.getItem(K.logs.density)==="compact"?"compact":"comfortable"}function vt(){if(typeof window>"u")return oe[0];const s=window.localStorage.getItem(K.logs.pageSize),l=Number(s);return oe.includes(l)?l:oe[0]}function Ge(s,l=!1){if(!s)return;const i=l?`${s}T23:59:59.999`:`${s}T00:00:00.000`,a=Date.parse(i);return Number.isFinite(a)?a:void 0}function Nt(s,l,i){return s===i&&l===i}function wt(s){const{t:l}=Q(),{activeFilters:i,filtersExpanded:a,setFiltersExpanded:o,handleResetFilters:t,activeQuickView:d,applyQuickView:c,providerFilter:g,setProviderFilter:h,endpointFilter:f,setEndpointFilter:C,selectedApiKeys:N,setSelectedApiKeys:m,modelFilter:_,setModelFilter:r,clientKindFilter:w,setClientKindFilter:b,sessionFilter:y,setSessionFilter:x,statusFilter:L,setStatusFilter:u,fromDate:F,setFromDate:R,toDate:$,setToDate:S,providerOptions:M,apiKeys:E,apiKeysLoading:A,customEndpoints:G}=s;return e.jsx(es,{"data-testid":"logs-filters-card",className:"overflow-hidden",children:e.jsxs(ss,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:l("logs.filtersTitle")}),i.length>0&&e.jsx(le,{variant:"outline",className:"border-transparent bg-secondary px-2.5 py-0.5 text-[11px] font-semibold text-foreground",children:l("common.filters.activeCount",{count:i.length})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("logs.filtersDescription")})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[i.length>0&&e.jsx(D,{variant:"ghost",size:"sm",onClick:t,className:"h-8 px-3 text-xs",children:l("common.actions.reset")}),e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>o(j=>!j),className:"h-8 px-3 text-xs",children:a?e.jsxs(e.Fragment,{children:[l("common.filters.collapse"),e.jsx($s,{className:"ml-1 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:[l("common.filters.expand"),e.jsx(Vs,{className:"ml-1 h-4 w-4"})]})})]})]}),i.length>0?e.jsx("div",{className:"flex min-h-10 flex-wrap items-center gap-2 rounded-lg bg-secondary px-3 py-2",children:i.map(j=>e.jsxs(le,{variant:"outline",role:"button",tabIndex:0,className:"flex cursor-pointer items-center gap-1 border border-border bg-card px-2.5 py-1 text-[11px] font-semibold text-foreground/90 transition hover:bg-secondary",onClick:j.onRemove,onKeyDown:ie=>{(ie.key==="Enter"||ie.key===" ")&&(ie.preventDefault(),j.onRemove())},children:[j.label,e.jsx(Us,{className:"h-3 w-3","aria-hidden":"true"})]},j.key))}):null,e.jsx(ts,{value:d,onChange:c,className:"flex-wrap","aria-label":l("logs.filtersTitle"),options:yt.map(j=>({value:j,label:l(`logs.quickViews.${j}`)}))})]}),a&&e.jsxs("div",{className:"mt-3 grid gap-3 rounded-xl bg-secondary p-3 md:grid-cols-2 xl:grid-cols-4 animate-in fade-in slide-in-from-top-2 duration-200",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{children:l("logs.filters.provider")}),e.jsxs(pe,{value:g,onValueChange:h,children:[e.jsx(xe,{children:e.jsx(ge,{})}),e.jsxs(he,{children:[e.jsx(U,{value:"all",children:l("logs.filters.providerAll")}),M.map(j=>e.jsx(U,{value:j.id,children:j.label??j.id},j.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{children:l("logs.filters.endpoint")}),e.jsxs(pe,{value:f,onValueChange:C,children:[e.jsx(xe,{children:e.jsx(ge,{})}),e.jsxs(he,{children:[e.jsx(U,{value:"all",children:l("logs.filters.endpointAll")}),e.jsx(U,{value:"anthropic",children:l("logs.filters.endpointAnthropic")}),e.jsx(U,{value:"openai",children:l("logs.filters.endpointOpenAI")}),G==null?void 0:G.map(j=>e.jsx(U,{value:j.id,children:j.label||j.id},j.id))]})]})]}),e.jsx(ft,{className:"md:col-span-2",apiKeys:E,selected:N,disabled:A,onChange:m}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{children:l("logs.filters.modelId")}),e.jsx(ye,{value:_,onChange:j=>r(j.target.value),placeholder:l("logs.filters.modelPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{children:l("logs.filters.clientKind")}),e.jsxs(pe,{value:w,onValueChange:b,children:[e.jsx(xe,{children:e.jsx(ge,{})}),e.jsxs(he,{children:[e.jsx(U,{value:"all",children:l("logs.filters.clientKindAll")}),bt.map(j=>e.jsx(U,{value:j,children:l(`dashboard.usage.clientKinds.${j}`,{defaultValue:j})},j))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{children:l("logs.filters.status")}),e.jsxs(pe,{value:L,onValueChange:j=>u(j),children:[e.jsx(xe,{children:e.jsx(ge,{})}),e.jsxs(he,{children:[e.jsx(U,{value:"all",children:l("logs.filters.statusAll")}),e.jsx(U,{value:"success",children:l("logs.filters.statusSuccess")}),e.jsx(U,{value:"error",children:l("logs.filters.statusError")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{children:l("logs.filters.startDate")}),e.jsx(ye,{type:"date",value:F,onChange:j=>R(j.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(X,{children:l("logs.filters.endDate")}),e.jsx(ye,{type:"date",value:$,onChange:j=>S(j.target.value)})]}),e.jsxs("div",{className:"space-y-2 md:col-span-2",children:[e.jsx(X,{htmlFor:"logs-session-filter",children:l("logs.filters.session")}),e.jsx(ye,{id:"logs-session-filter",value:y,onChange:j=>x(j.target.value),placeholder:l("logs.filters.sessionPlaceholder"),className:"font-mono"})]})]})]})})}const Re={listRequest(s){return{url:"/api/logs",method:"GET",params:s}},detailRequest(s){return{url:s===null?"":`/api/logs/${s}`,method:"GET"}},async exportArchive(s,l){const i=await Ys.post("/api/logs/export",s,{responseType:"blob",timeout:l});return new Blob([i.data],{type:"application/zip"})}};function ms({apiKeyMap:s,logId:l,open:i,providerLabelMap:a}){var _;const{t:o}=Q(),{pushToast:t}=_e(),d=re(se.logs.detail(l),Re.detailRequest(l),{enabled:i&&l!==null,staleTime:3e4,gcTime:15e3,placeholderData:void 0});p.useEffect(()=>{!d.isError||!d.error||t({title:o("logs.detail.loadError"),description:d.error.message,variant:"error"})},[d.error,d.isError,t,o]);const c=p.useCallback(async(r,w,b)=>{if(!w){t({title:o("logs.detail.copy.empty",{label:r}),variant:"info"});return}try{await nt(w),t({title:o(b),variant:"success"})}catch(y){t({title:o("logs.detail.copy.failure"),description:y instanceof Error?y.message:o("logs.detail.copy.failureFallback"),variant:"error"})}},[t,o]),g=p.useCallback((r,w)=>{if(!w){t({title:o("logs.detail.copy.empty",{label:r}),variant:"info"});return}const b=new Blob([w],{type:"application/json;charset=utf-8"}),y=URL.createObjectURL(b),x=document.createElement("a"),L=new Date().toISOString().replace(/[:.]/g,"-"),u=r.trim().toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]+/gi,"-").replace(/^-+|-+$/g,"")||"payload";x.href=y,x.download=`cc-gw-log-${l??"payload"}-${u}-${L}.json`,document.body.appendChild(x),x.click(),document.body.removeChild(x),URL.revokeObjectURL(y)},[l,t,o]),h=d.data,f=h?a.get(h.provider)??h.provider:"",C=h&&h.api_key_id!=null?s.get(h.api_key_id):void 0,N=h?it(h,o):null,m=h?Le(h,o):null;return{apiKeyMeta:C,errorSourceMeta:N,errorMessage:d.isError?((_=d.error)==null?void 0:_.message)??null:null,handleCopy:c,handleDownloadPayload:g,isError:d.isError,isPending:d.isPending,providerLabel:f,refetch:d.refetch,record:h,statusMeta:m}}function ps({detail:s,compact:l=!1}){var d;const{t:i}=Q(),a=c=>i(`logs.detail.errorDetail.stages.${c}`,{defaultValue:c}),o=e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.stage?e.jsx("span",{className:"border border-border bg-secondary px-1.5 py-0.5 text-[11px] font-medium text-foreground",children:a(s.stage)}):null,s.upstreamStatus!=null?e.jsxs("span",{className:"border border-destructive/40 bg-destructive/10 px-1.5 py-0.5 text-[11px] font-semibold tabular-nums text-destructive",children:["HTTP ",s.upstreamStatus]}):null,(d=s.failoverAttempts)!=null&&d.length?e.jsx("span",{className:"text-[11px] text-muted-foreground",children:i("logs.detail.errorDetail.attemptsCount",{count:s.failoverAttempts.length})}):null]}),t=s.failoverAttempts??[];return e.jsx(Zs,{defaultOpen:!0,summaryClassName:"px-1 py-1",contentClassName:v("mt-1 space-y-2",l&&"text-[11px]"),summary:e.jsx("span",{className:v("text-xs font-medium text-foreground",l&&"text-[11px]"),children:i("logs.detail.errorDetail.title")}),children:e.jsxs("div",{className:"space-y-2","data-testid":"log-error-detail",children:[o,s.message?e.jsx("p",{className:v("whitespace-pre-wrap break-all border-l-2 border-destructive/50 bg-destructive/5 px-2.5 py-1.5 font-mono",l?"text-[10.5px] leading-[1.55]":"text-[11px] leading-[1.6]"),children:s.message}):null,t.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left text-muted-foreground",children:[e.jsx("th",{className:"py-1 pr-3 font-medium",children:i("logs.detail.errorDetail.attemptBackend")}),e.jsx("th",{className:"py-1 pr-3 font-medium",children:i("logs.detail.errorDetail.attemptOutcome")}),e.jsx("th",{className:"py-1 pr-3 text-right font-medium",children:i("logs.detail.errorDetail.attemptStatus")}),e.jsx("th",{className:"py-1 text-right font-medium",children:i("logs.detail.errorDetail.attemptLatency")})]})}),e.jsx("tbody",{className:"tabular-nums",children:t.map((c,g)=>e.jsxs("tr",{className:"border-b border-border/50 last:border-b-0",children:[e.jsxs("td",{className:"py-1 pr-3",children:[e.jsx("span",{className:"font-medium",children:c.provider??"—"}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",c.model??"—"]})]}),e.jsx("td",{className:"py-1 pr-3 text-muted-foreground",children:c.outcome??"—"}),e.jsx("td",{className:"py-1 pr-3 text-right",children:c.status!=null?e.jsx("span",{className:c.status>=400?"text-destructive":"text-foreground",children:c.status}):"—"}),e.jsx("td",{className:"py-1 text-right text-muted-foreground",children:c.latencyMs!=null?`${c.latencyMs} ms`:"—"})]},g))})]})}):null,s.upstreamBody?e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:v("text-muted-foreground",l?"text-[10.5px]":"text-[11px]"),children:i("logs.detail.errorDetail.upstreamBody")}),e.jsx("pre",{className:v("m-0 max-h-[180px] overflow-auto whitespace-pre-wrap border border-border bg-secondary/50 p-2 font-mono text-muted-foreground",l?"text-[10.5px] leading-[1.55]":"text-[11px] leading-[1.6]"),children:s.upstreamBody})]}):null]})})}function kt({open:s,logId:l,onClose:i,providerLabelMap:a,apiKeyMap:o}){var y,x,L,u,F,R,$;const{t}=Q(),{apiKeyMeta:d,errorSourceMeta:c,errorMessage:g,handleCopy:h,handleDownloadPayload:f,isError:C,isPending:N,providerLabel:m,refetch:_,record:r,statusMeta:w}=ms({apiKeyMap:o,logId:l,open:s,providerLabelMap:a}),b=p.useMemo(()=>{var M,E,A,G;return r?[{key:"client-request",title:t("logs.detail.payload.clientRequest"),value:((M=r.payload)==null?void 0:M.client_request)??null,emptyLabel:t("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"},...(E=r.payload)!=null&&E.upstream_request?[{key:"upstream-request",title:t("logs.detail.payload.upstreamRequest"),value:r.payload.upstream_request,emptyLabel:t("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"}]:[],...(A=r.payload)!=null&&A.upstream_response?[{key:"upstream-response",title:t("logs.detail.payload.upstreamResponse"),value:r.payload.upstream_response,emptyLabel:t("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}]:[],{key:"client-response",title:t("logs.detail.payload.clientResponse"),value:((G=r.payload)==null?void 0:G.client_response)??null,emptyLabel:t("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}].map(j=>({...j,display:ns(j.value,j.emptyLabel)})):[]},[r,t]);return e.jsx(et,{open:s,onOpenChange:S=>{S||i()},children:e.jsxs(st,{className:"w-[min(96vw,1200px)] max-w-[1200px]",children:[e.jsxs(tt,{className:"pr-14",children:[e.jsx(lt,{children:t("logs.detail.title")}),e.jsx(at,{children:r?t("logs.detail.id",{id:r.id}):t("logs.detail.loadError")})]}),e.jsx(rt,{className:"max-h-[78vh]",children:N?e.jsx(ot,{compact:!0,className:"min-h-[240px]",label:t("common.loading")}):C?e.jsx(ne,{compact:!0,className:"min-h-[240px]",tone:"danger",title:t("logs.detail.loadError"),description:g??t("common.unknownError"),action:e.jsx(D,{variant:"outline",onClick:()=>void _(),children:t("common.actions.refresh")})}):r?e.jsxs("div",{className:"space-y-6 text-sm",children:[e.jsxs("section",{className:"space-y-4 rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t("logs.detail.infoSection")}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border bg-secondary p-3 text-xs",children:e.jsx("span",{className:"font-medium",children:t("logs.detail.summary.route",{from:r.client_model??t("logs.detail.info.noRequestedModel"),to:r.model})})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(le,{variant:w==null?void 0:w.variant,children:(w==null?void 0:w.label)??"—"}),e.jsx(le,{variant:"outline",children:r.stream?t("logs.stream.streaming"):t("logs.stream.single")})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(q,{label:t("logs.detail.info.latency"),value:Z(r.latency_ms,t("common.units.ms"))}),e.jsx(q,{label:t("logs.detail.info.ttft"),value:Z(r.ttft_ms,t("common.units.ms"))}),e.jsx(q,{label:t("logs.detail.info.tpot"),value:Z(r.tpot_ms,t("common.units.msPerToken"))}),e.jsx(q,{label:t("logs.detail.info.errorSource"),value:(c==null?void 0:c.label)??"—"})]}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsx(V,{label:t("logs.detail.info.time"),value:Ee(r.timestamp)}),e.jsx(V,{label:t("logs.detail.info.sessionId"),value:r.session_id??"—"}),e.jsx(V,{label:t("logs.detail.info.endpoint"),value:r.endpoint||"—"}),e.jsx(V,{label:t("logs.detail.info.provider"),value:m}),e.jsx(V,{label:t("logs.detail.info.client"),value:r.client_kind??"—"}),e.jsx(V,{label:t("logs.detail.info.userAgent"),value:r.user_agent??"—"}),e.jsx(V,{label:t("logs.detail.info.requestedModel"),value:r.client_model??t("logs.detail.info.noRequestedModel")}),e.jsx(V,{label:t("logs.detail.info.model"),value:r.model})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(q,{label:t("logs.detail.info.inputTokens"),value:W(r.input_tokens)}),e.jsx(q,{label:t("logs.detail.info.cacheReadTokens"),value:W(r.cache_read_tokens)}),e.jsx(q,{label:t("logs.detail.info.cacheCreationTokens"),value:W(r.cache_creation_tokens)}),e.jsx(q,{label:t("logs.detail.info.outputTokens"),value:W(r.output_tokens)})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-5","data-testid":"log-cost-breakdown",children:[e.jsx(q,{label:t("logs.detail.cost.title"),value:ee(r.cost,r.cost_currency)}),r.cost!=null?e.jsxs(e.Fragment,{children:[e.jsx(q,{label:t("logs.detail.cost.input"),value:ee(((y=r.cost_breakdown)==null?void 0:y.input)??null,r.cost_currency)}),e.jsx(q,{label:t("logs.detail.cost.output"),value:ee(((x=r.cost_breakdown)==null?void 0:x.output)??null,r.cost_currency)}),e.jsx(q,{label:t("logs.detail.cost.cacheRead"),value:ee(((L=r.cost_breakdown)==null?void 0:L.cacheRead)??null,r.cost_currency)}),e.jsx(q,{label:t("logs.detail.cost.cacheCreation"),value:ee(((u=r.cost_breakdown)==null?void 0:u.cacheCreation)??null,r.cost_currency)})]}):null]}),r.cost==null&&!Ce(r)?e.jsx("p",{className:"text-xs text-muted-foreground/70",children:t("logs.detail.cost.unpricedHint")}):null,Ce(r)?e.jsx("p",{className:"text-xs text-muted-foreground/70",children:t("logs.detail.tokensNoUsageHint")}):null,r.error?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:t("logs.detail.info.error")}),e.jsx("p",{className:"rounded-xl border border-destructive/50 bg-destructive/10 p-3 text-xs text-destructive",children:r.error})]}):null,(()=>{const S=is(r);return S?"raw"in S?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:t("logs.detail.errorDetail.title")}),e.jsx("pre",{className:"m-0 max-h-[180px] overflow-auto whitespace-pre-wrap rounded-xl border border-border bg-secondary/50 p-3 font-mono text-[11px] leading-[1.6] text-muted-foreground",children:S.raw})]}):e.jsx(ps,{detail:S}):null})()]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs("section",{className:"space-y-3 rounded-lg border bg-card p-4",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t("logs.detail.apiKey.title")}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 sm:grid-cols-2",children:[e.jsx(V,{label:t("logs.detail.apiKey.name"),value:r.api_key_id==null&&!r.api_key_name?t("logs.detail.apiKey.missing"):d!=null&&d.isWildcard?t("apiKeys.wildcard"):(d==null?void 0:d.name)??r.api_key_name??t("logs.detail.apiKey.missing")}),e.jsx(V,{label:t("logs.detail.apiKey.identifier"),value:r.api_key_id??t("common.noData")}),e.jsx(V,{label:t("logs.detail.apiKey.masked"),value:d!=null&&d.isWildcard?t("apiKeys.wildcard"):(d==null?void 0:d.maskedKey)??r.api_key_name??t("logs.detail.apiKey.maskedUnavailable")}),e.jsx(V,{label:t("logs.detail.apiKey.lastUsed"),value:d!=null&&d.lastUsedAt?new Date(d.lastUsedAt).toLocaleString():t("common.noData")})]}),e.jsxs("div",{className:"rounded-lg border bg-secondary p-3 text-xs",children:[e.jsx("p",{className:"font-medium",children:t("logs.detail.apiKey.rawMasked")}),e.jsx("p",{className:"mt-1 break-all font-mono",children:r.api_key_value_available?r.api_key_value_masked??t("logs.detail.apiKey.rawUnavailable"):t("logs.detail.apiKey.rawUnavailable")}),e.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:t("logs.detail.apiKey.rawMaskedHint")})]})]}),e.jsxs("section",{className:"space-y-4 rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t("logs.detail.payload.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(F=r.payload)!=null&&F.upstream_request||(R=r.payload)!=null&&R.upstream_response?t("logs.detail.payload.helperWithUpstream"):t("logs.detail.payload.helperClientOnly")})]}),e.jsxs(ls,{defaultValue:($=b[0])==null?void 0:$.key,children:[e.jsx(as,{className:"w-full justify-start overflow-x-auto",children:b.map(S=>e.jsx(rs,{value:S.key,children:S.title},S.key))}),b.map(S=>e.jsx(os,{value:S.key,children:e.jsx(St,{title:S.title,display:S.display,onCopy:()=>h(S.title,S.value,S.copyToast),onDownload:()=>f(S.title,S.value),panelKey:S.key,t})},S.key))]})]})]})]}):e.jsx(ne,{compact:!0,className:"min-h-[240px]",title:t("logs.detail.loadError"),description:t("common.noData")})})]})})}function q({label:s,value:l}){return e.jsxs("div",{className:"min-w-0 rounded-lg border bg-secondary px-3 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:s}),e.jsx("p",{className:"mt-2 break-all text-sm font-semibold leading-6",children:l})]})}function V({label:s,value:l}){return e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:s}),e.jsx("dd",{className:"min-w-0 break-all whitespace-pre-wrap text-sm font-medium leading-6 text-foreground",children:l??"—"})]})}function St({display:s,onCopy:l,onDownload:i,panelKey:a,title:o,t}){return e.jsxs("div",{className:"space-y-3 rounded-lg border bg-secondary/40 p-4","data-testid":`log-payload-${a}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:o}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:l,children:[e.jsx(Ye,{className:"mr-2 h-3.5 w-3.5"}),t("common.actions.copy")]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:i,children:[e.jsx(Xe,{className:"mr-2 h-3.5 w-3.5"}),t("common.actions.download")]})]})]}),s.isTruncated?e.jsx("p",{className:"rounded-lg border border-warning/30 bg-warning-bg px-3 py-2 text-xs text-warning",children:t("logs.detail.payload.truncated",{shown:s.displayedLength.toLocaleString(),total:s.originalLength.toLocaleString()})}):null,e.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre rounded-lg border bg-secondary p-3 text-xs",children:s.text})]})}function Ct({autoRefresh:s,columnOptions:l,exporting:i,onExport:a,onRefresh:o,onResetColumns:t,onSetDensity:d,onToggleAutoRefresh:c,onToggleColumn:g,refreshing:h,rowDensity:f,visibleColumns:C,visibleColumnSet:N}){const{t:m}=Q(),_=JSON.stringify(C)===JSON.stringify(B);return e.jsxs("div",{className:"flex w-full flex-col gap-3 xl:w-auto xl:flex-row xl:items-center",children:[e.jsxs("div",{className:"grid w-full grid-cols-2 gap-2 sm:flex sm:flex-row sm:flex-wrap sm:items-center xl:w-auto xl:flex-nowrap",children:[e.jsx(ts,{block:!0,className:"col-span-2 w-full overflow-x-auto sm:w-auto",value:f,onChange:d,options:[{value:"comfortable",label:m("logs.table.density.comfortable")},{value:"compact",label:m("logs.table.density.compact")}]}),e.jsxs(ut,{children:[e.jsx(mt,{asChild:!0,children:e.jsx(D,{variant:"outline",size:"sm",className:"w-full sm:w-auto",children:m("logs.actions.columns")})}),e.jsxs(pt,{align:"end",className:"w-64 p-3",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("p",{className:"text-sm font-semibold",children:m("logs.actions.columns")}),e.jsx(D,{variant:"ghost",size:"sm",onClick:t,disabled:_,children:m("common.actions.reset")})]}),e.jsx("div",{className:"grid gap-1.5",children:l.map(r=>{const w=N.has(r.id);return e.jsxs("label",{className:v("flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2 text-sm transition hover:bg-accent",w&&"bg-secondary text-foreground"),children:[e.jsx("input",{type:"checkbox",checked:w,onChange:()=>g(r.id),className:"h-4 w-4 rounded border-border"}),e.jsx("span",{children:r.label})]},r.id)})})]})]}),e.jsxs(D,{variant:"outline",onClick:a,disabled:i,className:"w-full sm:w-auto",children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),m(i?"logs.actions.exporting":"logs.actions.export")]})]}),e.jsxs("div",{className:"flex w-full items-center gap-3 xl:w-auto",children:[e.jsxs("label",{className:"flex shrink-0 cursor-pointer items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(xt,{checked:s,onCheckedChange:c,"aria-label":m("logs.actions.autoRefresh")}),m("logs.actions.autoRefresh")]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:o,disabled:h,className:"shrink-0",children:[e.jsx(Qs,{className:v("mr-2 h-4 w-4",h&&"animate-spin")}),m(h?"common.actions.refreshing":"logs.actions.manualRefresh")]})]})]})}function _t({record:s,providerLabelMap:l,onSelect:i,costCurrency:a}){const{t:o}=Q(),t=Le(s,o),d=l.get(s.provider)??s.provider,c=ds(s.session_id),g=c==null?void 0:c.accentStyle;return e.jsxs("button",{type:"button","data-session-id":c==null?void 0:c.sessionId,"data-session-color":c==null?void 0:c.colorKey,style:g,onClick:()=>i(s.id),className:"w-full space-y-2 border-b border-border/50 px-4 py-3 text-left transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:Ee(s.timestamp)}),e.jsx(le,{variant:t.variant,className:"text-xs",children:t.label})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[e.jsx("span",{className:"min-w-0 truncate font-medium",title:d,children:d}),e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",title:s.model,children:s.model})]}),s.client_kind?e.jsx("div",{className:"text-[11px] text-muted-foreground/80",title:s.user_agent??void 0,children:s.client_kind}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs tabular-nums text-muted-foreground",children:[e.jsx("span",{children:Z(s.latency_ms,o("common.units.ms"))}),s.ttft_ms!=null?e.jsxs("span",{children:[o("logs.table.columns.latencyTtft")," ",W(s.ttft_ms)]}):null,s.cost!=null?e.jsx("span",{children:ee(s.cost,a)}):null]})]})}const Je={accent:"bg-foreground",ok:"bg-success",warn:"bg-warning",error:"bg-destructive"};function Lt({logId:s,providerLabelMap:l,apiKeyMap:i}){const{t:a}=Q(),{record:o,isPending:t,isError:d,errorMessage:c,statusMeta:g,providerLabel:h,handleCopy:f,refetch:C}=ms({apiKeyMap:i,logId:s,open:!0,providerLabelMap:l}),N=p.useMemo(()=>{var F,R,$,S;if(!o)return[];const u=[{key:"client-request",title:a("logs.detail.payload.clientRequest"),value:((F=o.payload)==null?void 0:F.client_request)??null,emptyLabel:a("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"}];return(R=o.payload)!=null&&R.upstream_request&&u.push({key:"upstream-request",title:a("logs.detail.payload.upstreamRequest"),value:o.payload.upstream_request,emptyLabel:a("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"}),($=o.payload)!=null&&$.upstream_response&&u.push({key:"upstream-response",title:a("logs.detail.payload.upstreamResponse"),value:o.payload.upstream_response,emptyLabel:a("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}),u.push({key:"client-response",title:a("logs.detail.payload.clientResponse"),value:((S=o.payload)==null?void 0:S.client_response)??null,emptyLabel:a("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}),u.map(M=>({...M,display:ns(M.value,M.emptyLabel)}))},[o,a]),[m,_]=p.useState("client-request"),r=N.find(u=>u.key===m)??N[0];if(t)return e.jsx("div",{className:"py-3",children:e.jsx(cs,{className:"h-28 w-full"})});if(d)return e.jsx(ne,{compact:!0,tone:"danger",title:a("logs.detail.loadError"),description:c??a("common.unknownError"),action:e.jsx(D,{variant:"outline",size:"sm",onClick:()=>void C(),children:a("common.actions.refresh")})});if(!o)return e.jsx(ne,{compact:!0,title:a("logs.detail.loadError"),description:a("common.noData")});const w=dt(o,h,a),b=a("common.units.ms"),y=[{label:a("logs.detail.info.status"),value:(g==null?void 0:g.label)??"—"},{label:a("logs.detail.info.latency"),value:Z(o.latency_ms,b)},{label:a("logs.detail.info.ttft"),value:Z(o.ttft_ms,b)},{label:a("logs.detail.info.inputTokens"),value:W(o.input_tokens)},{label:a("logs.detail.info.outputTokens"),value:W(o.output_tokens)},{label:a("logs.detail.info.cacheReadTokens"),value:W(o.cache_read_tokens)},{label:a("logs.detail.info.cost"),value:ee(o.cost,o.cost_currency)}],x=o.ttft_ms!=null,L=o.session_id;return e.jsxs("div",{"data-testid":"log-row-expanded",className:"grid gap-5 py-1 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"mb-3 text-[10.5px] font-semibold uppercase tracking-[0.06em] text-muted-foreground",children:a("logs.detail.trace.title")}),e.jsx("ol",{"data-testid":"log-trace-timeline",className:"flex flex-col",children:w.map((u,F)=>e.jsxs("li",{className:"grid grid-cols-[14px_1fr] gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center","aria-hidden":"true",children:[e.jsx("span",{className:v("mt-1 h-[9px] w-[9px] rounded-full",Je[u.tone])}),F<w.length-1?e.jsx("span",{className:"mt-[3px] w-px flex-1 bg-border"}):null]}),e.jsxs("div",{className:"pb-3.5",children:[e.jsxs("div",{className:"flex items-baseline gap-2.5",children:[e.jsx("span",{className:"text-xs font-semibold",children:u.title}),u.atLabel?e.jsx("span",{className:"text-[10.5px] tabular-nums text-muted-foreground",children:u.atLabel}):null,u.durLabel?e.jsx("span",{className:"ml-auto text-[10.5px] tabular-nums text-muted-foreground",children:u.durLabel}):null]}),u.detail?e.jsx("div",{className:"mt-1 text-[11px] leading-[1.55] text-muted-foreground",children:u.detail}):null,e.jsx("div",{className:"mt-1.5 h-1 w-full max-w-[220px] bg-secondary",children:e.jsx("div",{className:v("h-full",Je[u.tone]),style:{width:`${u.barPct}%`}})})]})]},u.id))}),x?null:e.jsx("p",{className:"mt-1 text-[10.5px] text-muted-foreground/70",children:a("logs.detail.trace.degraded")}),(()=>{const u=is(o);return!u||"raw"in u?null:e.jsx("div",{className:"mt-2 border-t border-border pt-2",children:e.jsx(ps,{detail:u,compact:!0})})})()]}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[e.jsx("div",{className:"grid grid-cols-3 gap-2",children:y.map(u=>e.jsxs("div",{className:"border border-border bg-card px-2.5 py-2",children:[e.jsx("div",{className:"text-[10.5px] text-muted-foreground",children:u.label}),e.jsx("div",{className:"mt-0.5 text-[13px] font-semibold tabular-nums",children:u.value})]},u.label))}),Ce(o)?e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:a("logs.detail.tokensNoUsageHint")}):null,e.jsx("div",{className:"border border-border bg-card",children:e.jsxs(ls,{value:r==null?void 0:r.key,onValueChange:_,children:[e.jsx(as,{className:"w-full justify-start overflow-x-auto",children:N.map(u=>e.jsx(rs,{value:u.key,className:"px-2.5 text-[10.5px]",children:u.title},u.key))}),N.map(u=>e.jsx(os,{value:u.key,className:"mt-0",children:e.jsx("pre",{"data-testid":`log-payload-${u.key}`,className:"m-0 max-h-[172px] overflow-auto whitespace-pre-wrap p-3 font-mono text-[10.5px] leading-[1.65] text-muted-foreground",children:u.display.text||a("logs.detail.payload.emptyRequest")})},u.key))]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(D,{variant:"outline",size:"sm",className:"h-[30px] flex-1",onClick:()=>{r&&f(r.title,r.value,r.copyToast)},children:[e.jsx(Ye,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":"true"}),a("logs.detail.inline.copyRequest")]}),L?e.jsx(D,{variant:"outline",size:"sm",className:"h-[30px] flex-1",onClick:()=>f(a("logs.detail.inline.copySession"),L,"logs.detail.inline.sessionCopied"),children:a("logs.detail.inline.copySession")}):null,e.jsx(D,{asChild:!0,variant:"outline",size:"sm",className:"h-[30px] flex-1",children:e.jsxs(us,{to:"/providers?tab=routing",children:[a("logs.detail.inline.viewRule"),e.jsx(Hs,{className:"ml-1.5 h-3.5 w-3.5","aria-hidden":"true"})]})})]})]})]})}function Et({record:s,providerLabelMap:l,apiKeyMap:i,onSelect:a,isExpanded:o,onToggleExpand:t,isEven:d,density:c,visibleColumnSet:g,costCurrency:h}){const{t:f}=Q(),C=l.get(s.provider)??s.provider,N=s.endpoint||"—",m=Le(s,f),_=s.client_model??f("logs.table.requestedModelFallback"),r=s.api_key_id!=null?i.get(s.api_key_id):void 0,w=s.api_key_id==null?f("logs.table.apiKeyUnknown"):r!=null&&r.isWildcard?f("apiKeys.wildcard"):r!=null&&r.name?r.name:s.api_key_name?s.api_key_name:f("logs.table.apiKeyUnknown"),b=c==="compact"?"px-3 py-1.5":"px-3 py-2",y=d?"bg-muted/30":"bg-background",x=ds(s.session_id),L=x==null?void 0:x.accentStyle,u=g.size+2,F=f(o?"logs.detail.inline.collapse":"logs.detail.inline.expand");return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{"data-log-id":s.id,"data-session-id":x==null?void 0:x.sessionId,"data-session-color":x==null?void 0:x.colorKey,className:v("transition-colors duration-160 ease-surface",d?"bg-muted/30":"",o?"bg-muted/50":"hover:bg-muted/50"),children:[e.jsx("td",{className:v("sticky left-0 z-10 text-xs",b,y),style:L,children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button","aria-expanded":o,"aria-label":F,onClick:()=>t(s.id),className:"-ml-0.5 inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:e.jsx(Ze,{className:v("h-3.5 w-3.5 transition-transform duration-160 ease-surface",o&&"rotate-90"),"aria-hidden":"true"})}),e.jsx("span",{"data-visual-volatile":"true",className:"metric-number whitespace-nowrap",children:Ee(s.timestamp)})]})}),g.has("endpoint")&&e.jsx("td",{className:v(b,"text-xs"),children:N}),g.has("provider")&&e.jsx("td",{className:v(b,"text-xs"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:C,children:C})}),g.has("client")&&e.jsx("td",{className:v(b,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[110px] truncate",title:s.user_agent??s.client_kind??"",children:s.client_kind??"—"})}),g.has("requestedModel")&&e.jsx("td",{className:v(b,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:_,children:_})}),g.has("routedModel")&&e.jsx("td",{className:v(b,"text-xs"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:s.model,children:s.model})}),g.has("apiKey")&&e.jsx("td",{className:v(b,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[90px] truncate",title:w,children:w})}),g.has("tokens")&&e.jsx("td",{className:v(b,"text-right text-xs tabular-nums"),children:s.input_tokens==null&&s.output_tokens==null?e.jsx("span",{className:"whitespace-nowrap text-muted-foreground/70",children:f("logs.table.tokensNoUsage")}):e.jsxs("span",{className:"whitespace-nowrap",children:[f("logs.table.columns.tokenIn")," ",W(s.input_tokens),e.jsx("span",{className:"mx-1 text-muted-foreground/50",children:"·"}),f("logs.table.columns.tokenOut")," ",W(s.output_tokens)]})}),g.has("cost")&&e.jsx("td",{className:v(b,"text-right text-xs tabular-nums align-top"),children:e.jsx("span",{className:"whitespace-nowrap",title:s.cost==null?f("logs.table.costUnpricedHint"):void 0,"data-testid":`log-cost-${s.id}`,children:ee(s.cost,h)})}),g.has("duration")&&e.jsx("td",{className:v(b,"text-right text-xs tabular-nums"),title:s.ttft_ms!=null||s.tpot_ms!=null?`${f("logs.table.columns.latencyTtft")} ${Z(s.ttft_ms,"ms")} · ${f("logs.table.columns.latencyTpot")} ${Z(s.tpot_ms,"ms/tk")}`:void 0,children:e.jsx("span",{"data-visual-volatile":"true",className:"whitespace-nowrap",children:Z(s.latency_ms,"ms")})}),g.has("status")&&e.jsx("td",{className:v(b,"text-center"),children:e.jsx(le,{variant:m.variant,className:"text-xs",children:m.label})}),g.has("error")&&e.jsx("td",{className:v(b,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:s.error??"",children:s.error?s.error:"—"})}),e.jsx("td",{className:v("sticky right-0 z-10 text-center",b,y),children:e.jsx(D,{variant:"outline",size:"sm",onClick:()=>a(s.id),children:f("logs.actions.detail")})})]}),o?e.jsx("tr",{"data-testid":`log-row-expanded-wrapper-${s.id}`,children:e.jsx("td",{colSpan:u,className:"border-t border-border bg-secondary/30 p-0",children:e.jsx("div",{className:"px-5 pb-5 pt-3",children:e.jsx(Lt,{logId:s.id,providerLabelMap:l,apiKeyMap:i})})})}):null]})}const z="whitespace-nowrap px-3 py-2.5 text-xs font-semibold text-muted-foreground";function Rt(s){const{t:l}=Q(),{tableScrollRef:i,visibleColumnSet:a,visibleColumnCount:o,logsError:t,logsPending:d,items:c,costCurrency:g,activeFiltersCount:h,total:f,handleResetFilters:C,handleRetry:N,providerLabelMap:m,apiKeyMap:_,handleOpenDetail:r,expandedLogId:w,onToggleExpand:b,rowDensity:y,showScrollHint:x,pageSize:L,setPageSize:u,page:F,totalPages:R,setPage:$}=s,S=e.jsx(ne,{compact:!0,tone:"danger",icon:e.jsx(Bs,{className:"h-5 w-5","aria-hidden":"true"}),title:l("logs.toast.listError.title"),description:t,action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[e.jsx(D,{variant:"outline",size:"sm",onClick:N,children:l("common.actions.refresh")}),h>0?e.jsx(D,{variant:"ghost",size:"sm",onClick:C,children:l("common.actions.reset")}):null]})}),M=e.jsx(ne,{compact:!0,tone:"primary",icon:e.jsx(Ws,{className:"h-5 w-5","aria-hidden":"true"}),title:h>0?l("logs.empty.filteredTitle"):l("logs.empty.title"),description:h>0?l("logs.empty.filteredSubtitle"):l("logs.empty.subtitle"),action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[h>0?e.jsx(D,{variant:"outline",size:"sm",onClick:C,children:l("logs.empty.actions.reset")}):null,e.jsx(D,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(us,{to:"/api-keys",children:l("logs.empty.actions.apiKeys")})})]})});return e.jsx(es,{variant:"solid",className:"overflow-hidden bg-card shadow-[var(--surface-shadow)]",children:e.jsxs(ss,{className:"p-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 bg-secondary/50 px-4 py-3 border-b border-border",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:l("logs.title")}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"metric-number",children:l("logs.summary.total",{value:f.toLocaleString()})}),e.jsx("span",{className:"mx-1.5 text-muted-foreground/50",children:"·"}),l("logs.table.visibleColumns",{count:o})]})]}),x?e.jsx("div",{className:"hidden md:flex",children:e.jsx(le,{variant:"outline",className:"bg-background text-muted-foreground",children:l(y==="compact"?"logs.table.density.compact":"logs.table.density.comfortable")})}):null]}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{ref:i,className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[1180px] text-sm",children:[e.jsx("thead",{className:"border-b border-border/50 bg-secondary/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:v(z,"sticky left-0 z-20 bg-secondary text-left"),children:l("logs.table.columns.time")}),a.has("endpoint")&&e.jsx("th",{className:v(z,"text-left"),children:l("logs.table.columns.endpoint")}),a.has("provider")&&e.jsx("th",{className:v(z,"text-left"),children:l("logs.table.columns.provider")}),a.has("client")&&e.jsx("th",{className:v(z,"text-left"),children:l("logs.table.columns.client")}),a.has("requestedModel")&&e.jsx("th",{className:v(z,"text-left"),children:l("logs.table.columns.requestedModel")}),a.has("routedModel")&&e.jsx("th",{className:v(z,"text-left"),children:l("logs.table.columns.routedModel")}),a.has("apiKey")&&e.jsx("th",{className:v(z,"text-left"),children:l("logs.table.columns.apiKey")}),a.has("tokens")&&e.jsx("th",{className:v(z,"text-right"),children:l("logs.table.columns.tokens")}),a.has("cost")&&e.jsx("th",{className:v(z,"text-right"),children:l("logs.table.columns.cost")}),a.has("duration")&&e.jsx("th",{className:v(z,"text-right"),children:l("logs.table.columns.duration")}),a.has("status")&&e.jsx("th",{className:v(z,"text-center"),children:l("logs.table.columns.status")}),a.has("error")&&e.jsx("th",{className:v(z,"text-left"),children:l("logs.table.columns.error")}),e.jsx("th",{className:v(z,"sticky right-0 z-20 bg-secondary text-center"),children:l("logs.table.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-border/50",children:d?Array.from({length:8}).map((E,A)=>e.jsx(ct,{columns:o},A)):t&&c.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:o,className:"px-3 py-6",children:S})}):c.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:o,className:"px-3 py-8 text-center text-sm text-muted-foreground",children:M})}):c.map((E,A)=>e.jsx(Et,{record:E,providerLabelMap:m,apiKeyMap:_,onSelect:r,isExpanded:E.id===w,onToggleExpand:b,isEven:A%2===0,density:y,visibleColumnSet:a,costCurrency:g},E.id))})]})}),x&&e.jsx("div",{className:"table-scroll-hint"})]}),e.jsx("div",{className:"md:hidden",children:d?e.jsx("div",{className:"space-y-3 p-4",children:Array.from({length:5}).map((E,A)=>e.jsx(cs,{className:"h-20 w-full"},A))}):t&&c.length===0?e.jsx("div",{className:"px-3 py-6",children:S}):c.length===0?e.jsx("div",{className:"px-3 py-8",children:M}):c.map(E=>e.jsx(_t,{record:E,providerLabelMap:m,onSelect:r,costCurrency:g},E.id))}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 bg-secondary/50 p-4 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 border border-border bg-secondary px-3 py-1.5",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:l("logs.table.pagination.perPage")}),e.jsxs(pe,{value:L.toString(),onValueChange:E=>u(Number(E)),children:[e.jsx(xe,{className:"h-8 w-[80px] bg-background",children:e.jsx(ge,{})}),e.jsx(he,{children:oe.map(E=>e.jsx(U,{value:E.toString(),children:E},E))})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border border-border bg-secondary px-2 py-1.5",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>$(E=>Math.max(E-1,1)),disabled:F<=1,children:[e.jsx(Gs,{className:"mr-1 h-4 w-4","aria-hidden":"true"}),l("logs.table.pagination.previous")]}),e.jsx("span",{className:"metric-number px-1 text-sm text-muted-foreground",children:l("logs.table.pagination.pageLabel",{page:R===0?0:F,total:R})}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>$(E=>R===0?E:Math.min(E+1,R)),disabled:R===0||F>=R,children:[l("logs.table.pagination.next"),e.jsx(Ze,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]})]})]})]})})}function Ft({exportTimeoutMs:s,queryParams:l,total:i}){const{t:a}=Q(),{pushToast:o}=_e(),[t,d]=p.useState(!1),c=p.useCallback(async()=>{if(!t){d(!0);try{const g=i>0?Math.min(i,5e3):1e3,h={...l,limit:g,offset:0},f=await Re.exportArchive(h,s),C=new Date().toISOString().replace(/[:.]/g,"-"),N=URL.createObjectURL(f),m=document.createElement("a");m.href=N,m.download=`cc-gw-logs-${C}.zip`,document.body.appendChild(m),m.click(),m.remove(),URL.revokeObjectURL(N),o({title:a("logs.toast.exportSuccess.title"),description:a("logs.toast.exportSuccess.desc"),variant:"success"})}catch(g){const h=Xs(g);o({title:a("logs.toast.exportError.title"),description:a("logs.toast.exportError.desc",{message:h.message}),variant:"error"})}finally{d(!1)}}},[s,t,o,l,a,i]);return{exporting:t,handleExport:c}}function Dt(){const s=p.useRef(null),[l,i]=p.useState(!1),a=p.useCallback(()=>{const o=s.current;if(!o)return;const t=o.scrollWidth-o.scrollLeft-o.clientWidth>1;i(t)},[]);return p.useEffect(()=>{const o=s.current;if(!o)return;a(),o.addEventListener("scroll",a,{passive:!0});const t=new ResizeObserver(a);return t.observe(o),()=>{o.removeEventListener("scroll",a),t.disconnect()}},[a]),{scrollRef:s,showScrollHint:l,updateScrollHint:a}}const Tt="cc-gw.logs.visible-columns-v2";function Kt(){if(typeof window>"u")return B;const s=window.localStorage.getItem(Tt);if(!s)return B;try{const l=JSON.parse(s);if(!Array.isArray(l))return B;const i=l.filter(a=>te.includes(a));return i.length===0?B:(i.includes("cost")||i.push("cost"),i.sort((a,o)=>te.indexOf(a)-te.indexOf(o)))}catch{return B}}function Mt(){const[s,l]=I(K.logs.density,jt,{serialize:f=>f,deserialize:f=>f==="compact"?"compact":"comfortable"}),[i,a]=I(K.logs.visibleColumns,Kt,{serialize:JSON.stringify,deserialize:f=>{try{const C=JSON.parse(f);if(!Array.isArray(C))return B;const N=C.filter(m=>te.includes(m));return N.length>0?N:B}catch{return B}}}),{scrollRef:o,showScrollHint:t}=Dt(),d=p.useMemo(()=>new Set(i),[i]),c=i.length+2,g=p.useCallback(f=>{a(C=>{if(C.includes(f))return C.length===1?C:C.filter(m=>m!==f);const N=[...C,f];return N.sort((m,_)=>te.indexOf(m)-te.indexOf(_)),N})},[]);return{resetVisibleColumns:p.useCallback(()=>{a(B)},[]),rowDensity:s,setRowDensity:l,showScrollHint:t,tableScrollRef:o,toggleColumn:g,visibleColumnCount:c,visibleColumns:i,visibleColumnSet:d}}const Pt=3e3,At=200;function Ot(){var Pe,Ae,Oe,qe,ze,Ie;const{t:s}=Q(),{pushToast:l}=_e(),i=ht(),[a,o]=I(K.logs.providerFilter,"all"),[t,d]=I(K.logs.endpointFilter,"all"),[c,g]=I(K.logs.modelFilter,""),[h,f]=I(K.logs.clientKindFilter,"all"),[C,N]=I(K.logs.sessionFilter,""),[m,_]=I(K.logs.statusFilter,"all"),[r,w]=I(K.logs.fromDate,""),[b,y]=I(K.logs.toDate,""),[x,L]=p.useState(1),[u,F]=I(K.logs.autoRefresh,!0),[R,$]=I(K.logs.pageSize,vt,{serialize:n=>String(n),deserialize:n=>{const k=Number(n);return oe.includes(k)?k:oe[0]}}),[S,M]=p.useState(null),[E,A]=p.useState(!1),[G,j]=p.useState(null),[ie,xs]=p.useState(!1);p.useEffect(()=>{const n=document.querySelector('[data-testid="app-scroll"]'),k=()=>n?n.scrollTop:window.scrollY,T=()=>{xs(k()>=At)};T();const me=n??window;return me.addEventListener("scroll",T,{passive:!0}),()=>me.removeEventListener("scroll",T)},[]);const[P,de]=I(K.logs.selectedApiKeys,[],{serialize:JSON.stringify,deserialize:n=>{try{const k=JSON.parse(n);return Array.isArray(k)?k.map(T=>Number(T)).filter(T=>Number.isInteger(T)&&T>0):[]}catch{return[]}}}),[gs,hs]=p.useState(()=>typeof window>"u"||window.matchMedia("(min-width: 768px)").matches),{resetVisibleColumns:fs,rowDensity:ys,setRowDensity:bs,showScrollHint:js,tableScrollRef:vs,toggleColumn:Ns,visibleColumnCount:ws,visibleColumns:ks,visibleColumnSet:Ss}=Mt(),[H,Fe]=gt(),De=p.useRef(!1);p.useEffect(()=>{if(De.current)return;const n=["status","endpoint","provider","model","clientKind","session","from","to"];if(!n.some(Se=>H.has(Se)))return;De.current=!0,o("all"),d("all"),g(""),f("all"),N(""),_("all"),w(""),y(""),de([]);const k=H.get("status");(k==="success"||k==="error")&&_(k);const T=H.get("endpoint");T&&d(T);const me=H.get("provider");me&&o(me);const $e=H.get("model");$e&&g($e);const Ve=H.get("clientKind");Ve&&f(Ve);const Ue=H.get("session");Ue&&N(Ue);const Qe=H.get("from");Qe&&w(Qe);const He=H.get("to");He&&y(He);const Be=new URLSearchParams(H);for(const Se of n)Be.delete(Se);Fe(Be,{replace:!0})},[H,f,d,w,g,o,Fe,de,N,_,y]);const Cs=p.useDeferredValue(c),O=c===""?"":Cs,_s=p.useDeferredValue(C),J=C===""?"":_s;p.useEffect(()=>{L(1),j(null)},[a,t,O,h,J,m,r,b,R,P]);const be=p.useMemo(()=>{const n={limit:R,offset:(x-1)*R};a!=="all"&&(n.provider=a),t!=="all"&&(n.endpoint=t),O.trim().length>0&&(n.model=O.trim()),h!=="all"&&(n.clientKind=h),J.trim().length>0&&(n.session=J.trim()),m!=="all"&&(n.status=m);const k=Ge(r),T=Ge(b,!0);return k!==void 0&&(n.from=k),T!==void 0&&(n.to=T),P.length>0&&(n.apiKeys=P.join(",")),n},[O,J,h,t,r,x,R,a,P,m,b]),Y=re(se.logs.list(be),Re.listRequest(be),{gcTime:6e4,refetchInterval:u&&x===1&&G===null&&!E&&!ie?Pt:!1}),ae=re(se.providers.all(),We.providersRequest()),Te=re(se.apiKeys.all(),{url:"/api/keys",method:"GET"}),je=re(se.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"}),Ke=re(se.config.exportTimeout(),We.configRequest());p.useEffect(()=>{!Y.isError||!Y.error||l({title:s("logs.toast.listError.title"),description:s("logs.toast.listError.desc",{message:Y.error.message}),variant:"error"})},[Y.error,Y.isError,l,s]),p.useEffect(()=>{!ae.isError||!ae.error||l({title:s("logs.toast.providerError.title"),description:s("logs.toast.providerError.desc",{message:ae.error.message}),variant:"error"})},[ae.error,ae.isError,l,s]);const fe=((Pe=Y.data)==null?void 0:Pe.total)??0,ce=fe>0?Math.ceil(fe/R):0,Ls=((Ae=Y.data)==null?void 0:Ae.items)??[],Es=(Oe=Y.data)==null?void 0:Oe.cost_currency,Rs=p.useMemo(()=>{var k;const n=(k=Ke.data)==null?void 0:k.logExportTimeoutSeconds;return typeof n=="number"&&Number.isFinite(n)?Math.min(Math.max(Math.round(n),5),600)*1e3:6e4},[(qe=Ke.data)==null?void 0:qe.logExportTimeoutSeconds]);p.useEffect(()=>{ce>0&&x>ce&&L(ce)},[x,ce]);const ve=ae.data??[],Ne=p.useMemo(()=>{const n=new Map;for(const k of ve)k.id&&n.set(k.id,k.label??k.id);return n},[ve]),Me=p.useMemo(()=>{var k;const n=new Map;n.set("anthropic",s("logs.filters.endpointAnthropic")),n.set("openai",s("logs.filters.endpointOpenAI"));for(const T of((k=je.data)==null?void 0:k.endpoints)??[])n.set(T.id,T.label||T.id);return n},[(ze=je.data)==null?void 0:ze.endpoints,s]),Fs=p.useMemo(()=>{const n=[];if(a!=="all"){const k=Ne.get(a)??a;n.push({key:"provider",label:`${s("logs.filters.provider")}: ${k}`,onRemove:()=>o("all")})}if(t!=="all"){const k=Me.get(t)??t;n.push({key:"endpoint",label:`${s("logs.filters.endpoint")}: ${k}`,onRemove:()=>d("all")})}if(O.trim()&&n.push({key:"model",label:`${s("logs.filters.modelId")}: ${O.trim()}`,onRemove:()=>g("")}),h!=="all"&&n.push({key:"clientKind",label:`${s("logs.filters.clientKind")}: ${s(`dashboard.usage.clientKinds.${h}`,{defaultValue:h})}`,onRemove:()=>f("all")}),J.trim()&&n.push({key:"session",label:`${s("logs.filters.session")}: ${J.trim()}`,onRemove:()=>N("")}),m!=="all"){const k=s(m==="success"?"logs.filters.statusSuccess":"logs.filters.statusError");n.push({key:"status",label:`${s("logs.filters.status")}: ${k}`,onRemove:()=>_("all")})}return r&&n.push({key:"from",label:`${s("logs.filters.startDate")}: ${r}`,onRemove:()=>w("")}),b&&n.push({key:"to",label:`${s("logs.filters.endDate")}: ${b}`,onRemove:()=>y("")}),P.length>0&&n.push({key:"apiKeys",label:s("logs.filters.apiKeySelected",{count:P.length}),onRemove:()=>de([])}),n},[O,J,h,t,Me,r,a,Ne,P.length,m,s,b]),we=Te.data??[],Ds=p.useMemo(()=>{const n=new Map;for(const k of we)n.set(k.id,k);return n},[we]),Ts=p.useMemo(()=>te.map(n=>({id:n,label:s(`logs.table.columns.${n}`)})),[s]),ue=p.useMemo(()=>{const n=new Date;return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`},[]),Ks=p.useMemo(()=>h!=="all"||J.trim()!==""?null:a==="all"&&t==="all"&&O.trim()===""&&m==="all"&&r===""&&b===""&&P.length===0?"all":m==="error"&&t==="all"&&a==="all"&&O.trim()===""&&r===""&&b===""&&P.length===0?"errors":Nt(r,b,ue)&&t==="all"&&a==="all"&&O.trim()===""&&m==="all"&&P.length===0?"today":t==="anthropic"&&a==="all"&&O.trim()===""&&m==="all"&&r===""&&b===""&&P.length===0?"anthropic":t==="openai"&&a==="all"&&O.trim()===""&&m==="all"&&r===""&&b===""&&P.length===0?"openai":null,[O,J,h,t,r,a,P.length,m,b,ue]),ke=p.useCallback(()=>{o("all"),g(""),f("all"),N(""),d("all"),_("all"),w(""),y(""),de([])},[]),Ms=p.useCallback(n=>{if(L(1),ke(),n!=="all"){if(n==="errors"){_("error");return}if(n==="today"){w(ue),y(ue);return}if(n==="anthropic"){d("anthropic");return}n==="openai"&&d("openai")}},[ke,ue]),{exporting:Ps,handleExport:As}=Ft({exportTimeoutMs:Rs,queryParams:be,total:fe}),Os=p.useCallback(n=>{i.removeQueries({queryKey:["logs","detail"],type:"inactive"}),M(n),A(!0)},[i]),qs=p.useCallback(()=>{A(!1)},[]),zs=p.useCallback(n=>{j(k=>k===n?null:n)},[]);return p.useEffect(()=>{E||S===null||(i.removeQueries({queryKey:se.logs.detail(S),exact:!0}),M(null))},[E,i,S]),{activeFilters:Fs,activeQuickView:Ks,apiKeyMap:Ds,apiKeys:we,apiKeysQuery:Te,applyQuickView:Ms,autoRefresh:u,clientKindFilter:h,columnOptions:Ts,customEndpoints:(Ie=je.data)==null?void 0:Ie.endpoints,endpointFilter:t,exporting:Ps,expandedLogId:G,filtersExpanded:gs,fromDate:r,handleCloseDetail:qs,handleExport:As,handleOpenDetail:Os,handleResetFilters:ke,handleToggleExpand:zs,isDetailOpen:E,items:Ls,costCurrency:Es,logsQuery:Y,modelFilter:c,page:x,pageSize:R,providerFilter:a,providerLabelMap:Ne,providerOptions:ve,rowDensity:ys,resetVisibleColumns:fs,selectedApiKeys:P,selectedLogId:S,sessionFilter:C,setAutoRefresh:F,setClientKindFilter:f,setEndpointFilter:d,setFiltersExpanded:hs,setFromDate:w,setModelFilter:g,setPage:L,setPageSize:$,setProviderFilter:o,setRowDensity:bs,setSelectedApiKeys:de,setSessionFilter:N,setStatusFilter:_,setToDate:y,showScrollHint:js,statusFilter:m,tableScrollRef:vs,toDate:b,toggleColumn:Ns,total:fe,totalPages:ce,visibleColumnCount:ws,visibleColumns:ks,visibleColumnSet:Ss}}function rl(){var l;const s=Ot();return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Js,{actions:e.jsx(Ct,{autoRefresh:s.autoRefresh,columnOptions:s.columnOptions,exporting:s.exporting,onExport:()=>void s.handleExport(),onRefresh:()=>void s.logsQuery.refetch(),onResetColumns:s.resetVisibleColumns,onSetDensity:s.setRowDensity,onToggleAutoRefresh:s.setAutoRefresh,onToggleColumn:s.toggleColumn,refreshing:s.logsQuery.isFetching,rowDensity:s.rowDensity,visibleColumns:s.visibleColumns,visibleColumnSet:s.visibleColumnSet})}),e.jsx(wt,{activeFilters:s.activeFilters,filtersExpanded:s.filtersExpanded,setFiltersExpanded:s.setFiltersExpanded,handleResetFilters:s.handleResetFilters,activeQuickView:s.activeQuickView,applyQuickView:s.applyQuickView,providerFilter:s.providerFilter,setProviderFilter:s.setProviderFilter,endpointFilter:s.endpointFilter,setEndpointFilter:s.setEndpointFilter,selectedApiKeys:s.selectedApiKeys,setSelectedApiKeys:s.setSelectedApiKeys,modelFilter:s.modelFilter,setModelFilter:s.setModelFilter,clientKindFilter:s.clientKindFilter,setClientKindFilter:s.setClientKindFilter,sessionFilter:s.sessionFilter,setSessionFilter:s.setSessionFilter,statusFilter:s.statusFilter,setStatusFilter:s.setStatusFilter,fromDate:s.fromDate,setFromDate:s.setFromDate,toDate:s.toDate,setToDate:s.setToDate,providerOptions:s.providerOptions,apiKeys:s.apiKeys,apiKeysLoading:s.apiKeysQuery.isLoading,customEndpoints:s.customEndpoints}),e.jsx(Rt,{tableScrollRef:s.tableScrollRef,visibleColumnSet:s.visibleColumnSet,visibleColumnCount:s.visibleColumnCount,logsError:s.logsQuery.isError?((l=s.logsQuery.error)==null?void 0:l.message)??null:null,logsPending:s.logsQuery.isPending,items:s.items,costCurrency:s.costCurrency,activeFiltersCount:s.activeFilters.length,total:s.total,handleResetFilters:s.handleResetFilters,handleRetry:()=>void s.logsQuery.refetch(),providerLabelMap:s.providerLabelMap,apiKeyMap:s.apiKeyMap,handleOpenDetail:s.handleOpenDetail,expandedLogId:s.expandedLogId,onToggleExpand:s.handleToggleExpand,rowDensity:s.rowDensity,showScrollHint:s.showScrollHint,pageSize:s.pageSize,setPageSize:s.setPageSize,page:s.page,totalPages:s.totalPages,setPage:s.setPage}),e.jsx(kt,{open:s.isDetailOpen,logId:s.selectedLogId,onClose:s.handleCloseDetail,providerLabelMap:s.providerLabelMap,apiKeyMap:s.apiKeyMap})]})}export{rl as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./vendor-JUtelXU0.js";import{j as d}from"./app-CRxPj2SJ.js";import{c as l}from"./global-BLUcvOa8.js";function p({title:a,description:e,eyebrow:t,actions:r,className:x,contentClassName:n,children:c}){const m=a||e||t||r;return s.jsxs("div",{className:l(d({variant:"default"}),x),children:[m&&s.jsxs("div",{className:"flex flex-col gap-4 p-6 pb-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[t?s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-primary/80",children:t}):null,typeof a=="string"?s.jsx("h2",{className:"text-base font-semibold text-foreground",children:a}):a,e&&(typeof e=="string"?s.jsx("p",{className:"text-sm text-muted-foreground/70",children:e}):s.jsx("div",{className:"text-sm text-muted-foreground/70",children:e}))]}),r&&s.jsx("div",{className:"w-full shrink-0 sm:w-auto",children:r})]}),s.jsx("div",{className:l("p-6",!m&&"pt-6",n),children:c})]})}export{p as P};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,T as u}from"./vendor-JUtelXU0.js";import{c as n}from"./global-BLUcvOa8.js";const x={default:"border-border/30 bg-card",primary:"border-foreground/10 bg-card",danger:"border-destructive/15 bg-card"},c={default:"bg-secondary text-muted-foreground",primary:"bg-secondary text-foreground",danger:"bg-destructive/10 text-destructive"};function o({icon:r,title:t,description:s,action:a,className:l,compact:i=!1,inline:m=!1,tone:d="default"}){return m?e.jsxs("div",{className:n("flex flex-wrap items-center justify-center gap-x-2.5 gap-y-1.5 rounded-lg border border-dashed px-4 py-3 text-center",x[d],l),children:[r?e.jsx("span",{className:n("flex h-6 w-6 shrink-0 items-center justify-center rounded-md",c[d]),children:r}):null,e.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),s?e.jsx("span",{className:"text-sm text-muted-foreground",children:s}):null,a?e.jsx("span",{className:"flex flex-wrap items-center gap-2",children:a}):null]}):e.jsxs("div",{className:n("flex flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 text-center",i?"min-h-[180px] py-8":"min-h-[260px] py-12",x[d],l),children:[r?e.jsx("div",{className:n("mb-4 flex h-12 w-12 items-center justify-center rounded-2xl",c[d]),children:r}):null,e.jsxs("div",{className:"max-w-xl space-y-1.5",children:[e.jsx("div",{className:"text-base font-semibold tracking-[-0.01em]",children:t}),s?e.jsx("div",{className:"text-sm text-muted-foreground",children:s}):null]}),a?e.jsx("div",{className:"mt-5 flex flex-wrap items-center justify-center gap-2",children:a}):null]})}function g({label:r,className:t,compact:s=!1}){return e.jsx(o,{className:t,compact:s,tone:"primary",icon:e.jsx(u,{className:"h-5 w-5 animate-spin","aria-hidden":"true"}),title:r})}export{g as P,o as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as x,j as r}from"./vendor-JUtelXU0.js";import{c as d}from"./global-BLUcvOa8.js";import{o as u}from"./app-CRxPj2SJ.js";import{u as f}from"./i18n-v60Yn7Ls.js";import{b as p}from"./router-CqUBCAsx.js";function g(){var s;const{t:l}=f(),i=p(),e=(s=u(i.pathname))==null?void 0:s.nav,t=e?l(e.titleKey??e.labelKey):"";return x.useEffect(()=>{document.title=t?`${t} · cc-gw`:"cc-gw"},[t]),{title:t,description:e!=null&&e.descriptionKey?l(e.descriptionKey):""}}function y({title:l,description:i,info:e,status:t,actions:s,className:m}){const c=g(),n=l??c.title,o=i??c.description,a=t||e;return!n&&!a&&!s?null:r.jsxs("div",{className:d("flex flex-col gap-3",m),children:[(n||s)&&r.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[r.jsxs("div",{className:"min-w-0 space-y-1",children:[n?r.jsx("h1",{className:"truncate text-xl text-foreground",children:n}):null,o?r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o}):null]}),s?r.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:s}):null]}),a?r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[t,e]}):null]})}export{y as P};
|