@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/src/web/dist/index.html
CHANGED
|
@@ -4,24 +4,43 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
|
|
6
6
|
<meta name="format-detection" content="telephone=no" />
|
|
7
|
+
<script>
|
|
8
|
+
// 首帧前应用主题(防 FOUC)。与 ThemeProvider 同一套键:
|
|
9
|
+
// cc-gw-theme = light|dark|system(明暗),cc-gw-skin = 风格家族。
|
|
10
|
+
// 未知 skin 值落回 :root(minimal),boot 后由 ThemeProvider 清洗。
|
|
11
|
+
(function () {
|
|
12
|
+
try {
|
|
13
|
+
var root = document.documentElement
|
|
14
|
+
var mode = localStorage.getItem('cc-gw-theme')
|
|
15
|
+
if (mode !== 'light' && mode !== 'dark') mode = 'system'
|
|
16
|
+
var dark = mode === 'dark' ||
|
|
17
|
+
(mode === 'system' && window.matchMedia &&
|
|
18
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches)
|
|
19
|
+
root.dataset.theme = dark ? 'dark' : 'light'
|
|
20
|
+
root.classList.toggle('dark', dark)
|
|
21
|
+
var skin = localStorage.getItem('cc-gw-skin')
|
|
22
|
+
if (skin) root.dataset.skin = skin
|
|
23
|
+
} catch (e) { /* storage 不可用:保持 HTML 上的默认属性 */ }
|
|
24
|
+
})()
|
|
25
|
+
</script>
|
|
7
26
|
<link rel="icon" type="image/svg+xml" href="/cc-gw-mark.svg" />
|
|
8
27
|
<link rel="apple-touch-icon" href="/cc-gw-mark.svg" />
|
|
9
28
|
<link rel="manifest" href="/site.webmanifest" />
|
|
10
29
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
11
30
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
12
31
|
<link
|
|
13
|
-
href="https://fonts.googleapis.com/css2?family=Archivo:wght@400;600;800&family=Noto+Sans+SC:wght@400;500;700;900&display=swap"
|
|
32
|
+
href="https://fonts.googleapis.com/css2?family=Archivo:wght@400;600;800&family=Inter:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;700;900&family=Source+Serif+4:wght@600;700&display=swap"
|
|
14
33
|
rel="stylesheet"
|
|
15
34
|
/>
|
|
16
35
|
<title>cc-gw 控制台</title>
|
|
17
|
-
<script type="module" crossorigin src="/assets/app-
|
|
18
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-
|
|
19
|
-
<link rel="modulepreload" crossorigin href="/assets/global-
|
|
20
|
-
<link rel="modulepreload" crossorigin href="/assets/query-
|
|
21
|
-
<link rel="modulepreload" crossorigin href="/assets/i18n-
|
|
22
|
-
<link rel="modulepreload" crossorigin href="/assets/router-
|
|
23
|
-
<link rel="modulepreload" crossorigin href="/assets/radix-
|
|
24
|
-
<link rel="stylesheet" crossorigin href="/assets/global-
|
|
36
|
+
<script type="module" crossorigin src="/assets/app-CRxPj2SJ.js"></script>
|
|
37
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-JUtelXU0.js">
|
|
38
|
+
<link rel="modulepreload" crossorigin href="/assets/global-BLUcvOa8.js">
|
|
39
|
+
<link rel="modulepreload" crossorigin href="/assets/query-CvboQrUT.js">
|
|
40
|
+
<link rel="modulepreload" crossorigin href="/assets/i18n-v60Yn7Ls.js">
|
|
41
|
+
<link rel="modulepreload" crossorigin href="/assets/router-CqUBCAsx.js">
|
|
42
|
+
<link rel="modulepreload" crossorigin href="/assets/radix-d0BukFWM.js">
|
|
43
|
+
<link rel="stylesheet" crossorigin href="/assets/global-BQq8O0Tv.css">
|
|
25
44
|
</head>
|
|
26
45
|
<body class="bg-background text-foreground">
|
|
27
46
|
<div id="root"></div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
|
-
<html lang="zh-CN" data-theme="light">
|
|
2
|
+
<html lang="zh-CN" data-theme="light" data-skin="modernist">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
}
|
|
43
43
|
</script>
|
|
44
44
|
<title>cc-gw | 你的 API Key 不该躺在 30 个 .env 里 · local-first AI gateway</title>
|
|
45
|
-
<script type="module" crossorigin src="/assets/landing-
|
|
46
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-
|
|
47
|
-
<link rel="modulepreload" crossorigin href="/assets/global-
|
|
48
|
-
<link rel="modulepreload" crossorigin href="/assets/clipboard-
|
|
49
|
-
<link rel="modulepreload" crossorigin href="/assets/package-
|
|
50
|
-
<link rel="stylesheet" crossorigin href="/assets/global-
|
|
45
|
+
<script type="module" crossorigin src="/assets/landing-BQdbaG8s.js"></script>
|
|
46
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-JUtelXU0.js">
|
|
47
|
+
<link rel="modulepreload" crossorigin href="/assets/global-BLUcvOa8.js">
|
|
48
|
+
<link rel="modulepreload" crossorigin href="/assets/clipboard-DqvcglYs.js">
|
|
49
|
+
<link rel="modulepreload" crossorigin href="/assets/package-Dmrvm3RO.js">
|
|
50
|
+
<link rel="stylesheet" crossorigin href="/assets/global-BQq8O0Tv.css">
|
|
51
51
|
</head>
|
|
52
52
|
<body class="bg-slate-50 text-slate-900">
|
|
53
53
|
<div id="landing-root"></div>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as n,j as e,aX as q,aY as m,aq as B,W as R}from"./vendor-D2wC0h2o.js";import{P as F}from"./PageToolbar-BnDacS2l.js";import{P as p}from"./PageSection-Bv6dZZwN.js";import{P as M,a as C}from"./PageState-U6DpaNu4.js";import{u as z}from"./useAppMutation-Cix9n50u.js";import{a as D,c as G,B as x,q as I,r as $}from"./app-BnQl39hq.js";import{B as P}from"./badge-RZTsODn-.js";import{C as d,a as c}from"./card-DhuLMeO9.js";import{p as J}from"./package-CKkVmaOi.js";import{u as Q}from"./i18n-Dp-o1LhZ.js";import"./global-CJOj9WGx.js";import"./query-DVc6ZTRQ.js";import"./router-CUBM_FND.js";import"./radix-B9EIjzyN.js";function oe(){var h,g,f,v,j,N,y,w,k,S;const{t}=Q(),{pushToast:r}=D(),[i,A]=n.useState(null),a=G(I.status.gateway(),{url:"/api/status",method:"GET"},{staleTime:6e4});n.useEffect(()=>{a.isError&&a.error&&r({title:t("about.toast.statusError.title"),description:a.error.message,variant:"error"})},[r,a.error,a.isError,t]);const o=z({mutationFn:async()=>$({url:"/api/version/check",method:"GET"}),successToast:s=>s.updateAvailable?{title:t("about.toast.updateAvailable.title",{version:s.latestVersion}),description:t("about.toast.updateAvailable.description",{packageName:s.packageName})}:{title:t("about.toast.upToDate.title",{version:s.currentVersion}),description:t("about.toast.upToDate.description")},errorToast:s=>({title:t("about.toast.updateError.title"),description:s.message}),onSuccess:async s=>{A(s)}}),l=J.version,u="2026-08-28T03:43:01.225Z",V=n.useMemo(()=>{var s,T;return[{label:t("about.app.labels.name"),value:e.jsx("span",{className:"font-mono",children:"cc-gw"})},{label:t("about.app.labels.version"),value:e.jsxs("span",{"data-visual-volatile":"true",className:"font-mono text-primary",children:["v",l]})},{label:t("about.app.labels.buildTime"),value:e.jsx("span",{"data-visual-volatile":"true",children:u}),hint:t("about.app.hint.buildTime")},{label:t("about.app.labels.runtime"),value:e.jsx("span",{className:"font-mono",children:((s=a.data)==null?void 0:s.runtime)??"rust"})},{label:t("about.app.labels.backendVersion"),value:e.jsx("span",{"data-visual-volatile":"true",className:"font-mono",children:((T=a.data)==null?void 0:T.backendVersion)??"-"})}]},[l,u,(h=a.data)==null?void 0:h.backendVersion,(g=a.data)==null?void 0:g.runtime,t]),b=n.useMemo(()=>{var s;return a.data?[{label:t("about.status.labels.host"),value:a.data.host??"127.0.0.1"},{label:t("about.status.labels.port"),value:e.jsx("span",{"data-visual-volatile":"true",children:a.data.port.toLocaleString()})},{label:t("about.status.labels.providers"),value:a.data.providers.toLocaleString()},{label:t("about.status.labels.active"),value:(a.data.activeRequests??0).toLocaleString(),hint:t("about.status.hint.active")},{label:t("about.status.labels.platform"),value:a.data.platform??"-"},{label:t("about.status.labels.pid"),value:e.jsx("span",{"data-visual-volatile":"true",children:((s=a.data.pid)==null?void 0:s.toLocaleString())??"-"})}]:[]},[a.data,t]);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(F,{info:e.jsxs("span",{className:"rounded-lg bg-secondary px-2.5 py-1 text-xs text-muted-foreground","data-visual-volatile":"true",children:["v",l]}),status:e.jsx("span",{className:"rounded-lg bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:"manual refresh only"}),actions:e.jsxs(x,{onClick:()=>o.mutate(),disabled:o.isPending,size:"sm",children:[e.jsx(q,{className:`mr-2 h-4 w-4${o.isPending?" animate-spin":""}`,"aria-hidden":"true"}),o.isPending?t("about.support.actions.checkingUpdates"):t("about.support.actions.checkUpdates")]})}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(320px,0.85fr)]",children:[e.jsx(d,{className:"overflow-hidden",children:e.jsx(c,{className:"p-5",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg bg-secondary px-3 py-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[e.jsx(m,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Runtime snapshot"]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"metric-number truncate text-4xl font-semibold tracking-tight text-foreground",children:[((f=a.data)==null?void 0:f.host)??"127.0.0.1",":",((v=a.data)==null?void 0:v.port)??"-"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("about.description")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs sm:w-56",children:[e.jsx(L,{label:t("about.status.labels.providers"),value:((N=(j=a.data)==null?void 0:j.providers)==null?void 0:N.toLocaleString())??"-"}),e.jsx(L,{label:t("about.status.labels.active"),value:(((y=a.data)==null?void 0:y.activeRequests)??0).toLocaleString()})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(P,{variant:"outline",children:((w=a.data)==null?void 0:w.runtime)??"rust"}),e.jsx(P,{variant:"outline",children:((k=a.data)==null?void 0:k.platform)??"-"})]})]})})}),e.jsx(d,{className:"overflow-hidden",children:e.jsx(c,{className:"p-5",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Build"}),e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"font-mono text-xl font-semibold text-primary",children:["v",l]}),e.jsx("p",{"data-visual-volatile":"true",className:"text-xs text-muted-foreground",children:u})]}),i?e.jsxs("div",{className:"rounded-lg bg-secondary px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:i.updateAvailable?t("about.update.available",{version:i.latestVersion}):t("about.update.current",{version:i.currentVersion})}),e.jsxs("p",{className:"mt-1",children:[t("about.update.channel",{channel:i.channel}),i.publishedAt?` · ${new Date(i.publishedAt).toLocaleString()}`:""]})]}):null,e.jsx("div",{className:"rounded-lg bg-secondary px-3.5 py-3 text-sm text-muted-foreground",children:t("about.support.tip")})]})})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(p,{title:t("about.app.title"),description:t("about.app.subtitle"),children:e.jsx(E,{items:V})}),e.jsx(p,{title:t("about.status.title"),description:t("about.status.subtitle"),actions:e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),disabled:a.isFetching,children:[e.jsx(B,{className:U(a.isFetching),"aria-hidden":"true"}),a.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")]}),children:a.isLoading?e.jsx(M,{compact:!0,label:t("about.status.loading")}):a.isError?e.jsx(C,{compact:!0,tone:"danger",icon:e.jsx(m,{className:"h-5 w-5","aria-hidden":"true"}),title:t("common.status.error"),description:((S=a.error)==null?void 0:S.message)??t("common.unknownError"),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:t("common.actions.refresh")})}):b.length>0?e.jsx(E,{items:b}):e.jsx(C,{compact:!0,tone:"primary",icon:e.jsx(m,{className:"h-5 w-5","aria-hidden":"true"}),title:t("about.status.empty"),description:t("common.actions.refresh")})})]}),e.jsx(p,{title:t("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-medium text-primary",children:t("about.support.subtitle")}),e.jsx("span",{children:t("about.support.description")})]}),children:e.jsx(d,{className:"rounded-xl bg-card shadow-[var(--surface-shadow)]",children:e.jsxs(c,{className:"flex flex-col gap-4 pt-5 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 rounded-lg bg-secondary p-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-primary/10 text-primary",children:e.jsx(R,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:t("about.support.tip")})]}),e.jsx("code",{className:"inline-flex self-start rounded-lg bg-secondary px-3 py-2 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}function E({items:t}){return t.length===0?null:e.jsx("dl",{className:"grid gap-3 sm:grid-cols-2",children:t.map(r=>e.jsx(d,{className:"rounded-xl border border-border bg-secondary shadow-none",children:e.jsxs(c,{className:"p-4",children:[e.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:r.label}),e.jsx("dd",{className:"metric-number mt-2 text-sm font-semibold text-foreground",children:r.value}),r.hint?e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r.hint}):null]})},r.label))})}function L({label:t,value:r}){return e.jsxs("div",{className:"rounded-lg bg-secondary px-3 py-2 text-right",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:t}),e.jsx("p",{className:"metric-number mt-1 text-sm font-semibold text-foreground",children:r})]})}function U(t){return`mr-2 h-4 w-4${t?" animate-spin":""}`}export{oe as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as o,j as e,$ as xs,ak as te,U as Ce,aP as B,aQ as ie,as as us,aR as ve,aS as ms,aT as Ee,aM as De,ay as hs}from"./vendor-D2wC0h2o.js";import{a as ae,P as gs}from"./PageState-U6DpaNu4.js";import{P as ys}from"./PageToolbar-BnDacS2l.js";import{B as u,a as js,b as L,c as Y,s as O,q as N}from"./app-BnQl39hq.js";import{T as bs,a as vs,b as fe,c as Ke}from"./tabs-DYNHHISl.js";import{C as fs}from"./ConfirmDialog-BOe5HI56.js";import{D as ne,A as le,a as re,b as ce,c as Te,d as oe,e as de}from"./DialogShell-BbpG8sot.js";import{L as P,I as U}from"./label-Da-JMxO2.js";import{c as ke}from"./global-CJOj9WGx.js";import{E as Ae,R as Me,u as Ks}from"./shared-DHBfRHZV.js";import{u as w}from"./i18n-Dp-o1LhZ.js";import{L as Ns}from"./router-CUBM_FND.js";import{T as ws,a as Cs,b as Ne,c as W,d as Es,e as z,E as Ds}from"./table-rPjqxS-f.js";import{P as We}from"./PageSection-Bv6dZZwN.js";import{B as A}from"./badge-RZTsODn-.js";import{C as S,a as ze}from"./card-DhuLMeO9.js";import{M as Z}from"./metric-card-B_6litu2.js";import{S as qe}from"./segmented-control-D80bc13p.js";import{e as Ts}from"./charts-core-DlIzYcw_.js";import{u as H}from"./useAppMutation-Cix9n50u.js";import{a as q}from"./apiKeys-B-WRyKci.js";import{c as ks}from"./clipboard-BnAnBk_-.js";import"./query-DVc6ZTRQ.js";import"./radix-B9EIjzyN.js";import"./charts-react-Bz6GVFr3.js";import"./charts-engine-C14rMTiz.js";const Fe=o.forwardRef(({className:a,...s},p)=>e.jsx("textarea",{className:ke("flex min-h-[80px] w-full rounded-xl border border-border bg-card px-3 py-2.5 text-sm text-foreground ring-offset-background placeholder:text-muted-foreground/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:p,...s}));Fe.displayName="Textarea";function As({availableEndpoints:a,isOpen:s,keyDescription:p,keyName:i,maxConcurrency:r,onDescriptionChange:m,onEndpointsChange:y,onKeyNameChange:v,onMaxConcurrencyChange:x,onOpenChange:d,onSubmit:g,selectedEndpoints:n}){const{t:l}=w();return e.jsx(ne,{open:s,onOpenChange:d,children:e.jsxs(le,{className:"max-w-2xl",children:[e.jsxs(re,{children:[e.jsx(ce,{children:l("apiKeys.createNew")}),e.jsx(Te,{children:l("apiKeys.createDescription")})]}),e.jsxs(oe,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border border-primary/20 bg-accent px-4 py-3 text-xs text-primary",children:l("apiKeys.selectEndpoints")}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-3 text-xs text-primary",children:[e.jsx("p",{className:"font-semibold",children:"Restricted"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Select explicit endpoints before saving."})]}),e.jsxs("div",{className:"rounded-lg border border-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(P,{htmlFor:"keyName",children:[l("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(U,{id:"keyName",value:i,onChange:h=>v(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(P,{htmlFor:"keyDescription",children:l("apiKeys.descriptionLabel")}),e.jsx(Fe,{id:"keyDescription",value:p,onChange:h=>m(h.target.value),placeholder:l("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:l("apiKeys.allowedEndpoints")}),e.jsx(Ae,{available:a,selected:n,onChange:y,hint:l("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"maxConcurrency",children:l("apiKeys.maxConcurrency")}),e.jsx(U,{id:"maxConcurrency",type:"number",min:"0",value:r,onChange:h=>x(h.target.value),placeholder:l("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(de,{children:[e.jsx(u,{variant:"outline",onClick:()=>d(!1),children:l("common.actions.cancel")}),e.jsx(u,{onClick:g,children:l("apiKeys.createAction")})]})]})})}function Ms({createdKey:a,onClose:s,onCopy:p}){const{t:i}=w();return e.jsx(ne,{open:!!a,onOpenChange:r=>{r||s()},children:e.jsxs(le,{className:"max-w-xl",children:[e.jsx(re,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-success-bg text-success",children:e.jsx(xs,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(ce,{children:i("apiKeys.keyCreated")})]})}),e.jsxs(oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-warning",children:i("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 font-mono text-sm",children:a==null?void 0:a.key}),a!=null&&a.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:a.description}):null]}),e.jsxs(de,{children:[e.jsxs(u,{onClick:()=>p((a==null?void 0:a.key)??""),children:[e.jsx(te,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),i("common.actions.copy")]}),e.jsx(u,{variant:"outline",onClick:s,children:i("common.actions.close")})]})]})})}function Ws({apiKey:a,availableEndpoints:s,maxConcurrency:p,onClose:i,onEndpointsChange:r,onMaxConcurrencyChange:m,onSave:y,selectedEndpoints:v}){const{t:x}=w();return e.jsx(ne,{open:!!a,onOpenChange:d=>{d||i()},children:e.jsxs(le,{className:"max-w-2xl",children:[e.jsxs(re,{children:[e.jsx(ce,{children:x("apiKeys.editEndpoints")}),e.jsx(Te,{children:a==null?void 0:a.name})]}),e.jsxs(oe,{className:"space-y-4",children:[!(a!=null&&a.isWildcard)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border border-warning/30 bg-warning-bg px-4 py-3 text-xs text-warning",children:x("apiKeys.allEndpoints")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-xs text-muted-foreground",children:"Empty selection means unrestricted access. Only explicit selections create a restricted key scope."}),e.jsx(Ae,{available:s,selected:v,onChange:r,hint:x("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"editMaxConcurrency",children:x("apiKeys.maxConcurrency")}),e.jsx(U,{id:"editMaxConcurrency",type:"number",min:"0",value:p,onChange:d=>m(d.target.value),placeholder:x("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(de,{children:[e.jsx(u,{variant:"outline",onClick:i,children:x("common.actions.cancel")}),e.jsx(u,{onClick:y,children:x("common.save")})]})]})})}function zs({deleteTarget:a,isDeleting:s,onConfirm:p,onOpenChange:i}){const{t:r}=w();return e.jsx(fs,{open:!!a,onOpenChange:i,title:r("apiKeys.deleteDialogTitle"),description:r("apiKeys.confirmDelete"),confirmLabel:a&&s===a.id?r("common.actions.loading"):r("apiKeys.actions.delete"),cancelLabel:r("common.actions.cancel"),loading:a?s===a.id:!1,onConfirm:p,children:a?e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 font-mono text-xs text-foreground",children:a.name}):null})}function qs({onDismiss:a}){const{t:s}=w();return e.jsxs(S,{className:"relative p-3 sm:p-3.5",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"max-w-md space-y-1 pr-8",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-primary/75",children:"Recommended"}),e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:s("apiKeys.quickStart.title")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:s("apiKeys.quickStart.description")})]}),e.jsx("div",{className:"-mx-1 overflow-x-auto pb-1 lg:mx-0 lg:overflow-visible lg:pb-0",children:e.jsxs("div",{className:"flex gap-2 px-1 md:grid md:grid-cols-3 md:px-0 lg:max-w-3xl",children:[e.jsx(ee,{icon:e.jsx(Ce,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.create.title"),description:s("apiKeys.quickStart.create.description")}),e.jsx(ee,{icon:e.jsx(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(ie,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.wildcard.title"),description:s("apiKeys.quickStart.wildcard.description")})]})})]}),a?e.jsx(u,{variant:"ghost",size:"icon",className:"absolute right-1.5 top-1.5 h-7 w-7 text-muted-foreground hover:bg-secondary hover:text-foreground",onClick:a,"aria-label":s("common.actions.close"),children:e.jsx(us,{className:"h-4 w-4","aria-hidden":"true"})}):null]})}function Fs({activeKeysValue:a,enabledKeysValue:s,loading:p,onRangeChange:i,rangeDays:r,requestsChartOption:m,totalKeysValue:y,tokensChartOption:v,usageLength:x}){const{t:d}=w();return e.jsx(We,{title:d("apiKeys.analytics.title"),description:d("apiKeys.analytics.description",{days:r}),actions:e.jsx(qe,{className:"w-full overflow-x-auto sm:w-auto",value:r,onChange:i,options:Me.map(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(Z,{label:d("apiKeys.analytics.cards.total"),value:y,size:"sm"}),e.jsx(Z,{label:d("apiKeys.analytics.cards.enabled"),value:s,size:"sm"}),e.jsx(Z,{label:d("apiKeys.analytics.cards.active",{days:r}),value:a,size:"sm"})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(we,{title:d("apiKeys.analytics.charts.requests"),loading:p,empty:x===0,emptyText:d("apiKeys.analytics.empty"),option:m}),e.jsx(we,{title:d("apiKeys.analytics.charts.tokens"),loading:p,empty:x===0,emptyText:d("apiKeys.analytics.empty"),option:v})]})]})})}function Ls({filteredKeys:a,formatDate:s,hasWildcard:p,isDeleting:i,isRevealing:r,keys:m,onCopy:y,onDelete:v,onEditEndpoints:x,onFilterChange:d,onHide:g,onReveal:n,onStatusFilterChange:l,onToggleEnabled:h,revealedKeys:E,search:C,statusFilter:K,viewMode:T,onViewModeChange:j,onCreateKey:$}){const{t:b}=w();return e.jsx(We,{title:b("apiKeys.list.title"),description:p?b("apiKeys.wildcardHint"):void 0,actions:e.jsxs("div",{className:"flex w-full flex-wrap items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[e.jsx(qe,{value:T,onChange:j,options:[{value:"cards",label:b("apiKeys.views.cards"),icon:e.jsx(ve,{className:"h-3.5 w-3.5","aria-hidden":"true"})},{value:"compact",label:b("apiKeys.views.compact"),icon:e.jsx(ms,{className:"h-3.5 w-3.5","aria-hidden":"true"})}]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.jsx(A,{variant:"outline",children:`${a.length}/${m.length}`})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 rounded-xl bg-secondary p-4 sm:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx(U,{value:C,onChange:f=>d(f.target.value),placeholder:b("apiKeys.filters.searchPlaceholder")}),e.jsx("div",{className:"flex min-w-max items-center gap-1 overflow-x-auto rounded-full bg-background p-1 sm:justify-self-end",children:["all","enabled","disabled"].map(f=>e.jsx("button",{type:"button",onClick:()=>l(f),className:ke("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",K===f?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:b(`apiKeys.filters.${f}`)},f))})]}),m.length===0?e.jsx(ae,{compact:!0,tone:"primary",className:"rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(Ce,{className:"h-5 w-5","aria-hidden":"true"}),title:b("apiKeys.list.emptyTitle"),description:b("apiKeys.list.empty"),action:e.jsx(u,{size:"sm",onClick:$,children:b("apiKeys.createNew")})}):a.length===0?e.jsx(ae,{compact:!0,tone:"primary",className:"rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(ve,{className:"h-5 w-5","aria-hidden":"true"}),title:b("apiKeys.list.emptyFilteredTitle"),description:b("apiKeys.list.emptyFiltered"),action:e.jsx(u,{variant:"outline",size:"sm",onClick:()=>{d(""),l("all")},children:b("common.actions.reset")})}):T==="compact"?e.jsx(Os,{filteredKeys:a,formatDate:s,isDeleting:i,isRevealing:r,onCopy:y,onDelete:v,onEditEndpoints:x,onHide:g,onReveal:n,onToggleEnabled:h,revealedKeys:E}):e.jsx("div",{className:"grid gap-4",children:a.map(f=>e.jsx(Rs,{formatDate:s,isDeleting:i===f.id,isRevealing:r===f.id,keySummary:f,onCopy:y,onDelete:v,onEditEndpoints:x,onHide:g,onReveal:n,onToggleEnabled:h,revealedValue:E.get(f.id)},f.id))})]})})}function Os({filteredKeys:a,formatDate:s,isDeleting:p,isRevealing:i,onCopy:r,onDelete:m,onEditEndpoints:y,onHide:v,onReveal:x,onToggleEnabled:d,revealedKeys:g}){const{t:n}=w();return e.jsx(S,{className:"overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ws,{className:"min-w-[980px]",children:[e.jsx(Cs,{children:e.jsxs(Ne,{className:"bg-secondary/45 hover:bg-secondary/45",children:[e.jsx(W,{children:n("apiKeys.table.name")}),e.jsx(W,{children:n("apiKeys.table.access")}),e.jsx(W,{className:"text-right",children:n("apiKeys.requestCount")}),e.jsx(W,{className:"text-right",children:n("apiKeys.totalTokens")}),e.jsx(W,{className:"text-right",children:n("apiKeys.maxConcurrency")}),e.jsx(W,{children:n("apiKeys.lastUsed")}),e.jsx(W,{className:"w-[132px] text-right",children:n("apiKeys.table.actions")})]})}),e.jsx(Es,{children:a.map(l=>{var K,T,j;const h=g.get(l.id),E=(l.totalInputTokens+l.totalOutputTokens).toLocaleString(),C=l.isWildcard?n("apiKeys.wildcard"):(((K=l.allowedEndpoints)==null?void 0:K.length)??0)>0?(T=l.allowedEndpoints)==null?void 0:T.join(", "):n("apiKeys.allEndpoints");return e.jsxs(Ne,{children:[e.jsx(z,{className:"py-3",children:e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-foreground",children:l.name}),l.isWildcard?e.jsx(A,{variant:"secondary",className:"text-[11px]",children:n("apiKeys.wildcard")}):null,e.jsx(A,{variant:l.enabled?"default":"outline",className:"text-[11px]",children:l.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")})]}),l.isWildcard?null:e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("code",{className:"max-w-[220px] truncate rounded-md bg-secondary px-2 py-1 font-mono text-xs",children:h??l.maskedKey??"********"}),h?e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>r(h),"aria-label":n("common.actions.copy"),children:e.jsx(te,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(l.id),"aria-label":n("apiKeys.actions.hide"),children:e.jsx(ie,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>x(l.id),disabled:i===l.id,"aria-label":n("apiKeys.actions.reveal"),children:i===l.id?e.jsx("div",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Ee,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})}),e.jsx(z,{className:"py-3",children:e.jsxs("div",{className:"max-w-[180px]",children:[e.jsx("div",{className:"truncate text-sm text-foreground",title:C,children:C}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:l.isWildcard?n("apiKeys.table.accessWildcard"):(((j=l.allowedEndpoints)==null?void 0:j.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.table.accessOpen")})]})}),e.jsx(z,{className:"py-3 text-right font-medium",children:l.requestCount.toLocaleString()}),e.jsx(z,{className:"py-3 text-right font-medium",children:E}),e.jsx(z,{className:"py-3 text-right font-medium",children:l.maxConcurrency?String(l.maxConcurrency):"—"}),e.jsxs(z,{className:"py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:s(l.lastUsedAt)}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s(l.createdAt)})]}),e.jsx(z,{className:"py-3",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(u,{variant:"outline",size:"icon",onClick:()=>y(l),className:"h-8 w-8","aria-label":l.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints"),title:l.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints"),children:e.jsx(B,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(u,{variant:l.enabled?"outline":"default",size:"sm",onClick:()=>d(l.id,l.enabled),className:"h-8 px-2.5 text-xs",children:l.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),l.isWildcard?null:e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>m(l),disabled:p===l.id,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(De,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})})]},l.id)})})]})})})}function ee({description:a,icon:s,title:p}){return e.jsxs("div",{className:"w-[220px] shrink-0 rounded-xl border border-border bg-secondary p-3 md:w-auto",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-background text-primary sm:h-8 sm:w-8 sm:rounded-lg",children:s}),e.jsx("p",{className:"mt-2 text-[12px] font-semibold leading-5 text-foreground sm:mt-2.5 sm:text-[13px]",children:p}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-4.5 text-muted-foreground sm:text-xs sm:leading-5",children:a})]})}function Rs({formatDate:a,isDeleting:s,isRevealing:p,keySummary:i,onCopy:r,onDelete:m,onEditEndpoints:y,onHide:v,onReveal:x,onToggleEnabled:d,revealedValue:g}){var h,E,C;const{t:n}=w(),l=(i.totalInputTokens+i.totalOutputTokens).toLocaleString();return e.jsx(S,{"data-testid":"api-key-card",className:"overflow-hidden",children:e.jsx(ze,{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold",children:i.name}),i.isWildcard?e.jsx(A,{variant:"secondary",children:n("apiKeys.wildcard")}):null,e.jsx(A,{variant:i.enabled?"default":"outline",children:i.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")}),i.isWildcard?null:e.jsx(A,{variant:"outline",className:"text-xs",children:(((h=i.allowedEndpoints)==null?void 0:h.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.allEndpoints")}),!i.isWildcard&&i.allowedEndpoints&&i.allowedEndpoints.length>0?i.allowedEndpoints.map(K=>e.jsx(A,{variant:"outline",className:"text-xs",children:K},K)):i.isWildcard?null:e.jsx(A,{variant:"secondary",className:"text-xs opacity-60",children:n("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx(se,{label:n("apiKeys.requestCount"),value:i.requestCount.toLocaleString()}),e.jsx(se,{label:n("apiKeys.totalTokens"),value:l}),e.jsx(se,{label:n("apiKeys.maxConcurrency"),value:i.maxConcurrency?String(i.maxConcurrency):n("apiKeys.maxConcurrencyPlaceholder")})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("code",{className:"block max-w-full break-all rounded-lg bg-secondary px-3 py-1.5 font-mono text-sm",children:i.isWildcard?n("apiKeys.wildcard"):g??i.maskedKey??"********"}),i.isWildcard?null:e.jsx("div",{className:"flex items-center gap-1 self-start",children:g?e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>r(g),"aria-label":n("common.actions.copy"),title:n("common.actions.copy"),children:e.jsx(te,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>v(i.id),"aria-label":n("apiKeys.actions.hide"),title:n("apiKeys.actions.hide"),children:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(u,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>x(i.id),disabled:p,"aria-label":n("apiKeys.actions.reveal"),title:n("apiKeys.actions.reveal"),children:p?e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Ee,{className:"h-4 w-4","aria-hidden":"true"})})})]}),i.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:n("apiKeys.wildcardHint")}):i.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:i.description}):null,i.isWildcard?null:e.jsx("div",{className:"rounded-lg bg-secondary px-3 py-2 text-xs text-muted-foreground",children:(((E=i.allowedEndpoints)==null?void 0:E.length)??0)>0?`${n("apiKeys.allowedEndpoints")}: ${(C=i.allowedEndpoints)==null?void 0:C.join(", ")}`:n("apiKeys.allEndpoints")}),e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:a(i.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:a(i.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:flex lg:flex-wrap lg:justify-end",children:[e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>y(i),className:"w-full lg:w-auto",children:[e.jsx(B,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),i.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints")]}),e.jsx(u,{variant:i.enabled?"outline":"default",size:"sm",onClick:()=>d(i.id,i.enabled),className:"w-full lg:w-auto",children:i.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),i.isWildcard?null:e.jsx(u,{variant:"ghost",size:"icon",className:"h-9 w-full text-destructive hover:bg-destructive/10 hover:text-destructive sm:w-9",onClick:()=>m(i),disabled:s,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(De,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})})}function se({label:a,value:s}){return e.jsxs("div",{className:"rounded-lg bg-secondary px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:s})]})}function we({empty:a,emptyText:s,loading:p,option:i,title:r}){const{t:m}=w();return e.jsx(S,{children:e.jsxs(ze,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:r}),p?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:m("common.loadingShort")})}):a?e.jsx(ae,{compact:!0,className:"min-h-[280px] rounded-xl border border-dashed border-border/40 bg-background",icon:e.jsx(B,{className:"h-5 w-5","aria-hidden":"true"}),title:s,description:m("apiKeys.analytics.emptyHint"),action:e.jsx(u,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(Ns,{to:"/logs",children:m("apiKeys.analytics.actions.logs")})})}):e.jsx(Ds,{echarts:Ts,option:i,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}function Ps(){const{t:a}=w(),{pushToast:s}=js(),[p,i]=o.useState(!1),[r,m]=o.useState(""),[y,v]=o.useState(""),[x,d]=o.useState([]),[g,n]=o.useState(""),[l,h]=o.useState(null),[E,C]=o.useState(null),[K,T]=o.useState(null),[j,$]=L(O.apiKeys.rangeDays,7,{serialize:t=>String(t),deserialize:t=>{const c=Number(t);return Me.some(D=>D.value===c)?c:7}}),[b,f]=o.useState(new Map),[Le,pe]=o.useState(null),[R,G]=o.useState(null),[I,xe]=o.useState([]),[_,ue]=o.useState(""),[X,Oe]=L(O.apiKeys.search,""),[V,Re]=L(O.apiKeys.statusFilter,"all",{serialize:t=>t,deserialize:t=>t==="enabled"||t==="disabled"?t:"all"}),[Pe,Ie]=L(O.apiKeys.viewMode,"compact",{serialize:t=>t,deserialize:t=>t==="cards"?"cards":"compact"}),[Ve,Qe]=L(O.apiKeys.activeTab,"inventory",{serialize:t=>t,deserialize:t=>t==="analytics"?"analytics":"inventory"}),[He,Ue]=L(O.apiKeys.quickStartDismissed,!1),Be=Ks(),me=Y(N.apiKeys.all(),q.listRequest()),Se=Y(N.apiKeys.overview(j),q.overviewRequest(j)),he=Y(N.apiKeys.usage(j),q.usageRequest(j)),ge=H({mutationFn:q.create,invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyCreated")}),errorToast:t=>({title:a("apiKeys.toast.createFailure",{message:t.message})})}),Q=H({mutationFn:({id:t,...c})=>q.update(t,c),invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyUpdated")}),errorToast:t=>({title:a("apiKeys.toast.updateFailure",{message:t.message})})}),ye=H({mutationFn:({id:t})=>q.delete(t),invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(j),N.apiKeys.usage(j)],successToast:()=>({title:a("apiKeys.toast.keyDeleted")}),errorToast:t=>({title:a("apiKeys.toast.deleteFailure",{message:t.message})})}),je=H({mutationFn:({id:t})=>q.reveal(t),errorToast:t=>({title:a("apiKeys.toast.revealFailure"),description:t.message})}),M=me.data??[],F=Se.data,k=he.data??[],$e=M.some(t=>t.isWildcard),Ge=M.filter(t=>t.isWildcard).length,_e=M.filter(t=>{var c;return!t.isWildcard&&(((c=t.allowedEndpoints)==null?void 0:c.length)??0)>0}).length,Xe=M.filter(t=>{var c;return!t.isWildcard&&(((c=t.allowedEndpoints)==null?void 0:c.length)??0)===0}).length,Je=F?F.totalKeys.toLocaleString():"-",Ye=F?F.enabledKeys.toLocaleString():"-",Ze=F?F.activeKeys.toLocaleString():"-",es=o.useMemo(()=>M.filter(t=>{if(!(V==="all"||(V==="enabled"?t.enabled:!t.enabled)))return!1;const D=X.trim().toLowerCase();return D?[t.name,t.description??"",t.maskedKey??"",...t.allowedEndpoints??[]].join(" ").toLowerCase().includes(D):!0}),[M,X,V]),ss=o.useMemo(()=>{const t=k.map(c=>c.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:t,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.requestsSeries"),type:"bar",data:k.map(c=>c.requests),itemStyle:{color:"var(--primary)"}}]}},[a,k]),as=o.useMemo(()=>{const t=k.map(c=>c.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[a("apiKeys.analytics.tokens.input"),a("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:t,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:k.map(c=>c.inputTokens)},{name:a("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:k.map(c=>c.outputTokens)}]}},[a,k]),be=o.useCallback(()=>{m(""),v(""),d([]),n("")},[]),J=o.useCallback(t=>{i(t),t||be()},[be]),ts=o.useCallback(async()=>{if(!r.trim()){s({title:a("apiKeys.errors.nameRequired"),variant:"error"});return}const t=g.trim();if(t&&(!Number.isInteger(Number(t))||Number(t)<1)){s({title:a("apiKeys.errors.maxConcurrencyInvalid"),variant:"error"});return}try{const c=await ge.mutateAsync({name:r.trim(),description:y.trim()||void 0,allowedEndpoints:x.length>0?x:void 0,maxConcurrency:t?Number(t):null});h(c),J(!1)}catch{}},[ge,J,y,x,g,r,s,a]),is=o.useCallback(async(t,c)=>{try{await Q.mutateAsync({id:t,enabled:!c})}catch{}},[Q]),ns=o.useCallback(async()=>{if(K){C(K.id);try{await ye.mutateAsync({id:K.id}),T(null)}catch{}finally{C(null)}}},[K,ye]),ls=o.useCallback(async t=>{if(!b.has(t)){pe(t);try{const c=await je.mutateAsync({id:t});f(D=>new Map(D).set(t,c.key))}catch{}finally{pe(null)}}},[je,b]),rs=o.useCallback(t=>{f(c=>{const D=new Map(c);return D.delete(t),D})},[]),cs=o.useCallback(async t=>{try{await ks(t),s({title:a("apiKeys.toast.keyCopied"),variant:"success"})}catch(c){s({title:a("apiKeys.toast.copyFailure"),description:c instanceof Error?c.message:a("common.unknownError"),variant:"error"})}},[s,a]),os=o.useCallback(t=>{G(t),xe(t.allowedEndpoints??[]),ue(t.maxConcurrency?String(t.maxConcurrency):"")},[]),ds=o.useCallback(async()=>{if(!R)return;const t=_.trim();if(t&&(!Number.isInteger(Number(t))||Number(t)<1)){s({title:a("apiKeys.errors.maxConcurrencyInvalid"),variant:"error"});return}try{await Q.mutateAsync({id:R.id,...R.isWildcard?{}:{allowedEndpoints:I.length>0?I:null},maxConcurrency:t?Number(t):null}),G(null)}catch{}},[R,I,_,s,a,Q]),ps=o.useCallback(t=>t?new Date(t).toLocaleString():a("common.noData"),[a]);return{activeKeysValue:Ze,activeTab:Ve,availableEndpoints:Be,deleteTarget:K,editEndpointsKey:R,editEndpointsSelection:I,editMaxConcurrency:_,enabledKeysValue:Ye,filteredKeys:es,formatDate:ps,handleCopyKey:cs,handleCreateDialogChange:J,handleCreateKey:ts,handleDeleteKey:ns,handleHideKey:rs,handleOpenEditEndpoints:os,handleRevealKey:ls,handleSaveEndpoints:ds,handleToggleEnabled:is,hasWildcard:$e,isCreateDialogOpen:p,isDeleting:E,isRevealing:Le,keys:M,keysQuery:me,newKeyDescription:y,newKeyEndpoints:x,newKeyMaxConcurrency:g,newKeyName:r,newlyCreatedKey:l,quickStartDismissed:He,rangeDays:j,requestsChartOption:ss,restrictedCount:_e,revealedKeys:b,search:X,setQuickStartDismissed:Ue,setActiveTab:Qe,setDeleteTarget:T,setEditEndpointsKey:G,setEditEndpointsSelection:xe,setEditMaxConcurrency:ue,setNewKeyDescription:v,setNewKeyEndpoints:d,setNewKeyMaxConcurrency:n,setNewKeyName:m,setNewlyCreatedKey:h,setRangeDays:$,setSearch:Oe,setStatusFilter:Re,statusFilter:V,tokensChartOption:as,totalKeysValue:Je,unrestrictedCount:Xe,usage:k,usageQuery:he,viewMode:Pe,wildcardCount:Ge,setViewMode:Ie}}function xa(){const{t:a}=w(),s=Ps();if(s.keysQuery.isLoading)return e.jsx(gs,{label:a("common.loading")});const i=s.keys.filter(r=>!r.isWildcard).length===0&&!s.quickStartDismissed;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(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(u,{size:"sm",onClick:()=>s.handleCreateDialogChange(!0),children:[e.jsx(hs,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("apiKeys.createNew")]})}),i?e.jsx(qs,{onDismiss:()=>s.setQuickStartDismissed(!0)}):null,e.jsxs(bs,{value:s.activeTab,onValueChange:r=>s.setActiveTab(r),children:[e.jsxs(vs,{children:[e.jsx(fe,{value:"inventory",children:a("apiKeys.tabs.inventory")}),e.jsx(fe,{value:"analytics",children:a("apiKeys.tabs.analytics")})]}),e.jsx(Ke,{value:"inventory",className:"mt-4",children:e.jsx(Ls,{filteredKeys:s.filteredKeys,formatDate:s.formatDate,hasWildcard:s.hasWildcard,isDeleting:s.isDeleting,isRevealing:s.isRevealing,keys:s.keys,onCopy:r=>void s.handleCopyKey(r),onDelete:s.setDeleteTarget,onEditEndpoints:s.handleOpenEditEndpoints,onFilterChange:s.setSearch,onHide:s.handleHideKey,onReveal:r=>void s.handleRevealKey(r),onStatusFilterChange:s.setStatusFilter,onToggleEnabled:(r,m)=>void s.handleToggleEnabled(r,m),revealedKeys:s.revealedKeys,search:s.search,statusFilter:s.statusFilter,viewMode:s.viewMode,onViewModeChange:s.setViewMode,onCreateKey:()=>s.handleCreateDialogChange(!0)})}),e.jsx(Ke,{value:"analytics",className:"mt-4",children:e.jsx(Fs,{activeKeysValue:s.activeKeysValue,enabledKeysValue:s.enabledKeysValue,loading:s.usageQuery.isLoading,onRangeChange:s.setRangeDays,rangeDays:s.rangeDays,requestsChartOption:s.requestsChartOption,totalKeysValue:s.totalKeysValue,tokensChartOption:s.tokensChartOption,usageLength:s.usage.length})})]}),e.jsx(As,{availableEndpoints:s.availableEndpoints,isOpen:s.isCreateDialogOpen,keyDescription:s.newKeyDescription,keyName:s.newKeyName,maxConcurrency:s.newKeyMaxConcurrency,onDescriptionChange:s.setNewKeyDescription,onEndpointsChange:s.setNewKeyEndpoints,onKeyNameChange:s.setNewKeyName,onMaxConcurrencyChange:s.setNewKeyMaxConcurrency,onOpenChange:s.handleCreateDialogChange,onSubmit:()=>void s.handleCreateKey(),selectedEndpoints:s.newKeyEndpoints}),e.jsx(Ms,{createdKey:s.newlyCreatedKey,onClose:()=>s.setNewlyCreatedKey(null),onCopy:r=>void s.handleCopyKey(r)}),e.jsx(Ws,{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(zs,{deleteTarget:s.deleteTarget,isDeleting:s.isDeleting,onConfirm:()=>void s.handleDeleteKey(),onOpenChange:r=>{!r&&s.isDeleting===null&&s.setDeleteTarget(null)}})]})}export{xa as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,an as Se,ao as we,ap as ae,ac as Ce,O as H,r as b,aq as Le,T as Re}from"./vendor-D2wC0h2o.js";import{P as Ie}from"./PageToolbar-BnDacS2l.js";import{P as _,a as M}from"./PageState-U6DpaNu4.js";import{B as R,u as Me,a as qe,b as Ee,c as E,q as P,s as Pe}from"./app-BnQl39hq.js";import{S as ke,a as Ae,b as De,c as Oe,d as k}from"./select-BTwqvh0l.js";import{c as ze}from"./global-CJOj9WGx.js";import{L as I}from"./router-CUBM_FND.js";import{T as re,a as oe,b as D,c as T,d as ne,e as S,E as ie}from"./table-rPjqxS-f.js";import{P as $}from"./PageSection-Bv6dZZwN.js";import{S as Fe,C as Be,T as Ve,g as ee}from"./utils-HY2ZFw0f.js";import{B as L}from"./badge-RZTsODn-.js";import{C as le,a as de}from"./card-DhuLMeO9.js";import{D as ce}from"./disclosure-CJdf1-ap.js";import{M as g}from"./metric-card-B_6litu2.js";import{f as He,a as te,b as A,L as _e,T as $e,c as se}from"./types-DYz12j32.js";import{u as x}from"./i18n-Dp-o1LhZ.js";import{e as ue}from"./charts-core-DlIzYcw_.js";import{u as Ke}from"./useEventStream-CQTreYBE.js";import{a as Qe}from"./apiKeys-B-WRyKci.js";import{g as Ge}from"./gateway-DxCj_uok.js";import"./query-DVc6ZTRQ.js";import"./radix-B9EIjzyN.js";import"./charts-react-Bz6GVFr3.js";import"./charts-engine-C14rMTiz.js";function Ue(){return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:Array.from({length:4}).map((s,a)=>e.jsx(Fe,{},a))}),e.jsx(Be,{}),e.jsx("div",{className:"rounded-xl bg-card shadow-[var(--surface-shadow)]",children:e.jsx("table",{className:"w-full",children:e.jsx("tbody",{children:Array.from({length:5}).map((s,a)=>e.jsx(Ve,{columns:6},a))})})})]})}function We({status:s}){const{t:a}=x();return e.jsxs("div",{className:"space-y-3","data-testid":"dashboard-spotlight-grid",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm","data-testid":"dashboard-overview-panel",children:[e.jsx("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-success-bg px-1.5 py-0.5 text-[11px] font-medium text-success before:h-1.5 before:w-1.5 before:rounded-full before:bg-success before:animate-live-pulse",children:a("dashboard.status.listeningLabel")}),e.jsxs("span",{"data-testid":"dashboard-runtime-address",className:"metric-number text-sm font-semibold tracking-tight text-foreground",children:[(s==null?void 0:s.host)??"0.0.0.0",":",(s==null?void 0:s.port)??"-"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a("dashboard.status.providers",{value:(s==null?void 0:s.providers)??0})})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(g,{size:"md",label:a("dashboard.labels.activeRequests"),value:((s==null?void 0:s.activeRequests)??0).toLocaleString(),rawValue:(s==null?void 0:s.activeRequests)??0,valueTestId:"dashboard-spotlight-value-active"}),e.jsx(g,{size:"md",label:a("dashboard.labels.requestsPerMinute"),value:((s==null?void 0:s.requestsPerMinute)??0).toLocaleString(),rawValue:(s==null?void 0:s.requestsPerMinute)??0,valueTestId:"dashboard-spotlight-value-rpm"}),e.jsx(g,{size:"md",label:a("dashboard.labels.uniqueClientAddressesLastHour"),value:((s==null?void 0:s.uniqueClientAddressesLastHour)??0).toLocaleString(),rawValue:(s==null?void 0:s.uniqueClientAddressesLastHour)??0}),e.jsx(g,{size:"md",label:a("dashboard.labels.cpu"),value:He(s==null?void 0:s.cpuUsagePercent),valueTestId:"dashboard-spotlight-value-cpu"})]})]})}function Ye(s){switch(s){case"error":return e.jsx(L,{variant:"destructive",children:"error"});case"warn":return e.jsx(L,{variant:"warning",children:"warn"});default:return e.jsx(L,{variant:"secondary",children:"info"})}}function Je({overview:s}){const{t:a}=x(),t=s==null?void 0:s.today,r=s==null?void 0:s.yesterday,o=(t==null?void 0:t.requests)??0,n=(t==null?void 0:t.inputTokens)??0,l=(t==null?void 0:t.outputTokens)??0,i=(t==null?void 0:t.cacheReadTokens)??0,d=(t==null?void 0:t.errorCount)??0,h=o>0?d/o*100:0,O=r&&(r.requests??0)>0?r.errorCount/r.requests*100:void 0,c=i+n,z=c>0?i/c*100:0,w=(v,y)=>y!==void 0&&y>0?((v??0)-y)/y*100:void 0,f=v=>`${v>0?"+":""}${v.toFixed(1)}%`,C=(v,y=!1)=>v!==void 0&&Math.abs(v)>=.05?{value:v,invertColor:y,format:f}:void 0,F=o>0?w(h,O):void 0;return e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-5","data-testid":"dashboard-today-grid",children:[e.jsx(g,{size:"md",label:a("dashboard.cards.todayRequests"),value:o.toLocaleString(),rawValue:o,delta:C(w(o,r==null?void 0:r.requests)),hint:r&&r.requests>0?a("dashboard.cards.yesterdayHint",{value:r.requests.toLocaleString()}):void 0,valueTestId:"dashboard-today-value-requests"}),e.jsx(g,{size:"md",label:a("dashboard.cards.todayInput"),value:n.toLocaleString(),rawValue:n,suffix:a("common.units.token"),delta:C(w(n,r==null?void 0:r.inputTokens)),valueTestId:"dashboard-today-value-input"}),e.jsx(g,{size:"md",label:a("dashboard.cards.todayOutput"),value:l.toLocaleString(),rawValue:l,suffix:a("common.units.token"),delta:C(w(l,r==null?void 0:r.outputTokens)),valueTestId:"dashboard-today-value-output"}),e.jsx(g,{size:"md",label:a("dashboard.cards.todayCacheRead"),value:i.toLocaleString(),rawValue:i,suffix:a("common.units.token"),hint:c>0?a("dashboard.cards.cacheHitHint",{value:z.toFixed(1)}):void 0,valueTestId:"dashboard-today-value-cache-read"}),e.jsx(g,{size:"md",label:a("dashboard.cards.todayErrorRate"),value:h>0?e.jsxs("span",{className:"text-destructive",children:[h.toFixed(1),"%"]}):`${h.toFixed(1)}%`,delta:C(F,!0),hint:d>0?a("dashboard.cards.errorCountHint",{value:d}):void 0,valueTestId:"dashboard-today-value-error-rate"})]})}function Xe({connected:s,failed:a,events:t}){const{t:r}=x();return t.length===0?null:e.jsx($,{title:r("dashboard.attention.title"),description:r("dashboard.attention.subtitle"),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:a?"inline-flex items-center gap-1 text-[11px] font-medium text-destructive before:h-1.5 before:w-1.5 before:rounded-full before:bg-destructive":s?"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:r(a?"dashboard.attention.failed":s?"dashboard.attention.live":"dashboard.attention.reconnecting")}),e.jsx(R,{asChild:!0,variant:"ghost",size:"sm",className:"h-7",children:e.jsx(I,{to:"/events",children:r("dashboard.attention.viewAll")})})]}),children:e.jsx("ul",{className:"divide-y divide-border",children:e.jsx(we,{initial:!1,children:t.map(o=>e.jsxs(ae.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:Ye(o.level)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.title??o.type}),o.message?e.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:o.message}):null]}),e.jsx("span",{className:"shrink-0 pt-0.5 text-[11px] tabular-nums text-muted-foreground/70",children:new Date(o.createdAt).toLocaleTimeString()})]},o.id))})})})}function Ze({connected:s,failed:a}){const{t}=x();return e.jsxs(ae.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},transition:{duration:.18},"data-testid":"dashboard-all-clear",className:"flex h-8 flex-wrap items-center gap-x-2 gap-y-1 rounded-full bg-success-bg px-3 text-xs text-success",children:[e.jsx(Ce,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium",children:t("dashboard.attention.allClear")}),e.jsx("span",{className:a?"ml-auto inline-flex items-center gap-1.5 text-[11px] font-medium text-destructive before:h-1.5 before:w-1.5 before:rounded-full before:bg-destructive":s?"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:t(a?"dashboard.attention.failed":s?"dashboard.attention.live":"dashboard.attention.reconnecting")}),e.jsx(I,{to:"/events",className:"shrink-0 underline-offset-2 hover:underline",children:t("dashboard.attention.viewAll")})]})}function et({empty:s,loading:a,option:t}){const{t:r}=x();return e.jsx(lt,{title:r("dashboard.charts.trendTitle"),description:r("dashboard.charts.trendDesc"),loading:a,option:t,empty:s,emptyText:r("dashboard.charts.empty")})}function tt({daily:s,models:a}){const{t}=x();if(s.length===0&&a.length===0)return null;const r=s.reduce((d,h)=>d+h.requestCount,0),o=s.length>0?s.reduce((d,h)=>h.requestCount>d.requestCount?h:d,s[0]):null,n=a.length>0?a.reduce((d,h)=>h.requests>d.requests?h:d,a[0]):null,l=a.filter(d=>d.avgTtftMs!=null&&d.avgTtftMs>0).sort((d,h)=>(d.avgTtftMs??Number.POSITIVE_INFINITY)-(h.avgTtftMs??Number.POSITIVE_INFINITY))[0],i=[{label:t("dashboard.insights.totalRequests"),value:r>0?r.toLocaleString():"—",hint:r>0?t("dashboard.insights.totalRequestsHint"):void 0},{label:t("dashboard.insights.busiestDay"),value:o?o.date.slice(5):"—",hint:o?t("dashboard.insights.busiestDayHint",{value:o.requestCount.toLocaleString()}):void 0},{label:t("dashboard.insights.topModel"),value:n?n.model:"—",hint:n?t("dashboard.insights.topModelHint",{value:n.requests.toLocaleString()}):void 0},{label:t("dashboard.insights.fastestTtft"),value:l?l.model:"—",hint:l?t("dashboard.insights.fastestTtftHint",{value:Math.round(l.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:i.map(d=>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:d.label}),e.jsx("div",{className:"metric-number mt-2 truncate text-base font-bold tracking-tight text-foreground",children:d.value}),d.hint?e.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:d.hint}):null]},d.label))})}function st({modelRequestsOption:s,models:a,ttftOption:t,tpotOption:r}){const{t:o}=x();return e.jsxs(ce,{variant:"card",summaryClassName:"px-4 py-3",contentClassName:"border-t border-border px-4 py-4",summary:e.jsx("span",{className:"text-sm font-medium text-foreground",children:o("dashboard.sections.performance")}),children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsx(V,{title:o("dashboard.charts.modelTitle"),option:s,empty:!a.length}),e.jsx(V,{title:o("dashboard.charts.ttftTitle"),option:t,empty:!a.some(n=>n.avgTtftMs!=null&&n.avgTtftMs>0)}),e.jsx(V,{title:o("dashboard.charts.tpotTitle"),option:r,empty:!a.some(n=>n.avgTpotMs!=null&&n.avgTpotMs>0)})]}),e.jsx("div",{className:"mt-4",children:e.jsx(nt,{models:a,embedded:!0})})]})}function at({dbInfo:s,dbSizeDisplay:a,memoryDisplay:t,status:r}){const{t:o}=x();return e.jsx(ce,{variant:"card",summaryClassName:"px-4 py-3",contentClassName:"border-t border-border px-4 py-4",summary:e.jsx("span",{className:"text-sm font-medium text-foreground",children:o("dashboard.cards.systemResources")}),badge:e.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[a," · ",t]}),children:e.jsxs("div",{className:"grid gap-2.5 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(g,{size:"sm",label:o("dashboard.labels.networkIngress"),value:te(r==null?void 0:r.networkIngressBytesPerSecond),valueTestId:"dashboard-spotlight-value-ingress"}),e.jsx(g,{size:"sm",label:o("dashboard.labels.networkEgress"),value:te(r==null?void 0:r.networkEgressBytesPerSecond),valueTestId:"dashboard-spotlight-value-egress"}),e.jsx(g,{size:"sm",label:o("dashboard.labels.database"),value:a,valueTestId:"dashboard-spotlight-value-database"}),e.jsx(g,{size:"sm",label:o("dashboard.labels.memory"),value:t,valueTestId:"dashboard-spotlight-value-memory"})]})})}function rt({doneCount:s,total:a}){const{t}=x(),r=Math.min(100,Math.round(s/a*100));return e.jsxs("div",{"data-testid":"dashboard-setup-progress",className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-full bg-secondary/60 px-4 py-2",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:t("dashboard.setupProgress.label",{done:s,total:a})}),e.jsx("div",{className:"h-1.5 min-w-24 flex-1 overflow-hidden rounded-full bg-border/60",children:e.jsx("div",{className:"h-1.5 rounded-full bg-primary transition-all",style:{width:`${r}%`}})}),e.jsx(I,{to:"/setup",className:"shrink-0 text-xs font-medium text-primary underline-offset-2 hover:underline",children:t("dashboard.setupProgress.cta")})]})}function ot({endpointCount:s,providerCount:a}){const{t}=x(),r=[{title:t("dashboard.guide.step1Title"),description:a>0?t("dashboard.guide.step1DescDone",{count:a}):t("dashboard.guide.step1Desc"),href:"/providers",cta:t("dashboard.guide.step1Cta")},{title:t("dashboard.guide.step2Title"),description:s>0?t("dashboard.guide.step2DescDone",{count:s}):t("dashboard.guide.step2Desc"),href:"/providers",cta:t("dashboard.guide.step2Cta")},{title:t("dashboard.guide.step3Title"),description:t("dashboard.guide.step3Desc"),href:"/api-keys",cta:t("dashboard.guide.step3Cta")}];return e.jsx(le,{className:"relative overflow-hidden",children:e.jsxs(de,{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:t("dashboard.guide.title")}),e.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t("dashboard.guide.subtitle")})]}),e.jsx(R,{asChild:!0,size:"sm",children:e.jsx(I,{to:"/setup",children:t("dashboard.guide.startWizard")})})]}),e.jsx("ol",{className:"grid gap-3 lg:grid-cols-3",children:r.map((o,n)=>e.jsxs("li",{className:"rounded-lg border border-border p-4",children:[e.jsx("span",{className:"metric-number text-xs font-semibold text-muted-foreground",children:String(n+1).padStart(2,"0")}),e.jsx("h4",{className:"mt-2 text-sm font-semibold text-foreground",children:o.title}),e.jsx("p",{className:"mt-1.5 text-xs leading-6 text-muted-foreground",children:o.description}),e.jsx(R,{asChild:!0,variant:"ghost",size:"sm",className:"mt-2 h-8 px-0 text-primary hover:bg-transparent hover:text-primary/80",children:e.jsx(I,{to:o.href,children:o.cta})})]},o.title))})]})})}function nt({models:s,loading:a,embedded:t}){const{t:r}=x(),o=a?e.jsx(_,{compact:!0,label:r("common.loadingShort")}):s.length===0?e.jsx(M,{compact:!0,icon:e.jsx(H,{className:"h-5 w-5","aria-hidden":"true"}),title:r("dashboard.modelTable.empty")}):e.jsx("div",{className:"overflow-auto",children:e.jsxs(re,{children:[e.jsx(oe,{children:e.jsxs(D,{children:[e.jsx(T,{children:r("dashboard.modelTable.columns.model")}),e.jsx(T,{className:"text-right",children:r("dashboard.modelTable.columns.requests")}),e.jsx(T,{className:"text-right",children:r("dashboard.modelTable.columns.latency")}),e.jsx(T,{className:"text-right",children:r("dashboard.modelTable.columns.ttft")}),e.jsx(T,{className:"text-right",children:r("dashboard.modelTable.columns.tpot")})]})}),e.jsx(ne,{children:s.map(n=>e.jsxs(D,{children:[e.jsx(S,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:n.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n.model})]})}),e.jsx(S,{className:"text-right font-medium",children:n.requests.toLocaleString()}),e.jsx(S,{className:"text-right",children:A(n.avgLatencyMs,r("common.units.ms"))}),e.jsx(S,{className:"text-right",children:A(n.avgTtftMs,r("common.units.ms"))}),e.jsx(S,{className:"text-right",children:A(n.avgTpotMs,r("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${n.provider}/${n.model}`))})]})});return t?o:e.jsx($,{title:r("dashboard.modelTable.title"),description:r("dashboard.modelTable.description"),children:o})}function it({records:s,loading:a}){const{t}=x(),r=s.map(i=>ee(i,t)),o=r.filter(i=>i.tone==="success").length,n=r.filter(i=>i.tone==="error").length,l=r.filter(i=>i.tone==="pending").length;return e.jsx($,{title:t("dashboard.recent.title"),description:t("dashboard.recent.subtitle",{count:5}),actions:s.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(L,{variant:"secondary",children:s.length}),e.jsxs(L,{variant:"success",children:[t("common.status.success"),": ",o]}),e.jsxs(L,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[t("common.status.error"),": ",n]}),l>0?e.jsxs(L,{variant:"warning",children:[t("common.status.pending"),": ",l]}):null]}):null,children:a?e.jsx(_,{compact:!0,label:t("dashboard.recent.loading")}):s.length===0?e.jsx(M,{compact:!0,icon:e.jsx(Se,{className:"h-5 w-5","aria-hidden":"true"}),title:t("dashboard.recent.empty")}):e.jsx("div",{className:"overflow-auto",children:e.jsxs(re,{children:[e.jsx(oe,{children:e.jsxs(D,{children:[e.jsx(T,{children:t("dashboard.recent.columns.time")}),e.jsx(T,{children:t("dashboard.recent.columns.endpoint")}),e.jsx(T,{children:t("dashboard.recent.columns.provider")}),e.jsx(T,{children:t("dashboard.recent.columns.route")}),e.jsx(T,{className:"text-right",children:t("dashboard.recent.columns.latency")}),e.jsx(T,{children:t("dashboard.recent.columns.status")})]})}),e.jsx(ne,{children:s.map(i=>{const d=ee(i,t);return e.jsxs(D,{children:[e.jsx(S,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium",children:new Date(i.timestamp).toLocaleString()}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["#",i.id]})]})}),e.jsx(S,{children:e.jsx(L,{variant:"outline",className:"text-[11px]",children:i.endpoint==="anthropic"?t("logs.endpointAnthropic"):i.endpoint==="openai"?t("logs.endpointOpenAI"):i.endpoint})}),e.jsx(S,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:i.provider}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:i.stream?"stream":"sync"})]})}),e.jsx(S,{children:e.jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx("span",{children:i.client_model??t("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"->"}),e.jsx("span",{className:"font-medium text-foreground",children:i.model})]}),i.error?e.jsx("span",{className:"truncate text-destructive",children:i.error}):null]})}),e.jsx(S,{className:"text-right font-medium",children:A(i.latency_ms,t("common.units.ms"))}),e.jsx(S,{children:e.jsx(L,{variant:d.variant,className:"min-w-14 justify-center",children:d.label})})]},i.id)})})]})})})}function V({empty:s,option:a,title:t}){const{t:r}=x();return e.jsxs("div",{className:"rounded-lg border border-border p-3",children:[e.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:t}),s?e.jsx(M,{compact:!0,className:"min-h-[160px]",icon:e.jsx(H,{className:"h-4 w-4","aria-hidden":"true"}),title:r("dashboard.charts.empty")}):e.jsx(ie,{echarts:ue,option:a,className:"h-[220px]",notMerge:!0,lazyUpdate:!0})]})}function lt({description:s,empty:a,emptyText:t,loading:r,option:o,title:n}){const{t:l}=x();return e.jsx(le,{children:e.jsxs(de,{className:"space-y-4 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:n}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground/70",children:s})]}),r?e.jsx(_,{compact:!0,className:"min-h-[220px]",label:l("common.loadingShort")}):a?e.jsx(M,{compact:!0,className:"min-h-[188px] rounded-xl border border-dashed border-border/45 bg-muted",icon:e.jsx(H,{className:"h-5 w-5","aria-hidden":"true"}),title:t??l("dashboard.charts.empty"),description:s}):e.jsx("div",{className:"pt-2",children:e.jsx(ie,{echarts:ue,option:o,className:"h-[36vh] min-h-[260px] max-h-[400px]",notMerge:!0,lazyUpdate:!0})})]})})}function j(s,a){return typeof window>"u"?a:getComputedStyle(document.documentElement).getPropertyValue(s).trim()||a}function dt(){const{resolved:s}=Me();return b.useMemo(()=>{const a=j("--foreground","#201e1d"),t=j("--muted-foreground","#605d5d"),r=j("--border","#d7d3d3"),o=j("--card","#ffffff");return{palette:[j("--chart-1","#ec3013"),j("--chart-2","#ae1800"),j("--chart-3","#ff9783"),j("--chart-4","#444141"),j("--chart-5","#9b9797")],success:j("--success","#444141"),warning:j("--warning","#ae1800"),error:j("--error","#dd2b0f"),axis:t,splitLine:r,base:{textStyle:{color:t,fontSize:11},grid:{left:8,right:8,top:32,bottom:4,containLabel:!0},tooltip:{backgroundColor:o,borderColor:r,textStyle:{color:a,fontSize:12}},legend:{textStyle:{color:t,fontSize:11}}}}},[s])}const ct=4;function ut(s){var t;if(!s)return 0;let a=Object.keys(s.modelRoutes??{}).length;for(const r of Object.values(s.endpointRouting??{}))a+=Object.keys((r==null?void 0:r.modelRoutes)??{}).length;for(const r of s.customEndpoints??[])a+=Object.keys(((t=r.routing)==null?void 0:t.modelRoutes)??{}).length;return a}function ht(){var U,W,Y,J,X,Z;const{t:s}=x(),{pushToast:a}=qe(),t=dt(),[r,o]=Ee(Pe.dashboard.endpointFilter,"all"),n=r==="all"?void 0:r,l=E(P.dashboard.summary(r),{url:"/api/dashboard/summary",method:"GET",params:n?{endpoint:n}:void 0},{refetchInterval:_e}),i=E(P.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:$e}),d=Ke({level:"warn,error",maxEvents:20}),h=b.useRef(!1);b.useEffect(()=>{var m;const u=l.error!=null;u&&!h.current&&(h.current=!0,a({title:s("dashboard.toast.overviewError"),description:((m=l.error)==null?void 0:m.message)??"",variant:"error"})),u||(h.current=!1)},[l.error,a,s]);const O=b.useCallback(async()=>{await Promise.all([l.refetch(),i.refetch()])},[l,i]),c=l.data,z=c==null?void 0:c.overview,w=b.useMemo(()=>(c==null?void 0:c.daily)??[],[c]),f=b.useMemo(()=>(c==null?void 0:c.modelStats)??[],[c]),C=c==null?void 0:c.status,F=c==null?void 0:c.dbInfo,v=(c==null?void 0:c.recentRequests.items)??[],y=((C==null?void 0:C.providers)??0)>0,K=v.length>0,Q=E(P.config.full(),Ge.configRequest(),{enabled:y}),B=b.useMemo(()=>ut(Q.data),[Q.data])>0,G=(((U=E(P.apiKeys.all(),Qe.listRequest(),{enabled:y&&B}).data)==null?void 0:U.length)??0)>0,he=y&&B&&G&&K,me=[y,B,G,K].filter(Boolean).length,xe=b.useMemo(()=>{const u=(c==null?void 0:c.recentErrors)??[],m=new Set;return[...d.events,...u].filter(p=>!(m.has(p.id)||(m.add(p.id),n&&p.endpoint!==n))).slice(0,10)},[d.events,c,n]),pe=r==="all"?s("dashboard.filters.endpointAll"):r==="anthropic"?s("dashboard.filters.endpointAnthropic"):r==="openai"?s("dashboard.filters.endpointOpenAI"):((J=(Y=(W=i.data)==null?void 0:W.endpoints)==null?void 0:Y.find(u=>u.id===r))==null?void 0:J.label)||r,be=f.filter(u=>u.avgTtftMs!=null&&u.avgTtftMs>0).sort((u,m)=>(u.avgTtftMs??Number.POSITIVE_INFINITY)-(m.avgTtftMs??Number.POSITIVE_INFINITY))[0],ge=l.isFetching||i.isFetching,fe=l.isPending,je=((X=l.error)==null?void 0:X.message)??null,ve=b.useMemo(()=>{const u=s("dashboard.charts.barRequests"),m=s("dashboard.charts.latencyLabel");return{...t.base,color:t.palette,tooltip:{trigger:"axis",...t.base.tooltip},legend:{data:[u,m],...t.base.legend},grid:t.base.grid,xAxis:{type:"category",data:w.map(N=>N.date.slice(5)),axisLabel:{color:t.axis},axisLine:{lineStyle:{color:t.splitLine}}},yAxis:[{type:"value",name:u,nameTextStyle:{color:t.axis},axisLabel:{color:t.axis},splitLine:{lineStyle:{color:t.splitLine}}},{type:"value",name:m,nameTextStyle:{color:t.axis},axisLabel:{color:t.axis},splitLine:{show:!1}}],series:[{name:u,type:"bar",data:w.map(N=>N.requestCount),itemStyle:{color:t.palette[0],borderRadius:[4,4,0,0]},barMaxWidth:24},{name:m,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:w.map(N=>Math.round(N.avgLatencyMs)),itemStyle:{color:t.palette[3]},lineStyle:{width:2}}]}},[w,t,s]),q=b.useCallback((u,m,N)=>({...t.base,tooltip:{trigger:"axis",...t.base.tooltip},grid:{...t.base.grid,bottom:24},xAxis:{type:"category",data:f.map(p=>`${p.provider}/${p.model}`),axisLabel:{color:t.axis,rotate:28},axisLine:{lineStyle:{color:t.splitLine}}},yAxis:{type:"value",name:u,nameTextStyle:{color:t.axis},axisLabel:{color:t.axis},splitLine:{lineStyle:{color:t.splitLine}}},series:[{name:u,type:"bar",data:f.map(m),itemStyle:{color:N,borderRadius:[4,4,0,0]},barMaxWidth:32}]}),[f,t]),ye=b.useMemo(()=>q(s("dashboard.charts.ttftAxis"),u=>u.avgTtftMs??0,t.palette[2]),[q,t,s]),Ne=b.useMemo(()=>q(s("dashboard.charts.tpotAxis"),u=>u.avgTpotMs??0,t.palette[4]),[q,t,s]),Te=b.useMemo(()=>{const u=s("dashboard.charts.barRequests"),m=s("dashboard.charts.lineInput"),N=s("dashboard.charts.lineOutput");return{...t.base,color:t.palette,tooltip:{trigger:"axis",...t.base.tooltip},legend:{data:[u,m,N],...t.base.legend},grid:{...t.base.grid,bottom:24},xAxis:{type:"category",data:f.map(p=>`${p.provider}/${p.model}`),axisLabel:{color:t.axis,rotate:28},axisLine:{lineStyle:{color:t.splitLine}}},yAxis:[{type:"value",name:u,nameTextStyle:{color:t.axis},axisLabel:{color:t.axis},splitLine:{lineStyle:{color:t.splitLine}}},{type:"value",name:s("dashboard.charts.axisTokens"),position:"right",nameTextStyle:{color:t.axis},axisLabel:{color:t.axis},splitLine:{show:!1}}],series:[{name:u,type:"bar",data:f.map(p=>p.requests),itemStyle:{color:t.palette[0],borderRadius:[4,4,0,0]},barMaxWidth:24},{name:m,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:f.map(p=>p.inputTokens??0),itemStyle:{color:t.palette[1]},lineStyle:{width:2}},{name:N,type:"line",yAxisIndex:1,smooth:!0,showSymbol:!1,data:f.map(p=>p.outputTokens??0),itemStyle:{color:t.palette[2]},lineStyle:{width:2}}]}},[f,t,s]);return{attentionEvents:xe,customEndpoints:((Z=i.data)==null?void 0:Z.endpoints)??[],daily:w,dbInfo:F,endpointFilter:r,fastestTtftModel:be,handleRefresh:O,bootstrapError:je,isBootstrapping:fe,isRefreshing:ge,liveConnected:d.connected,liveFailed:d.failed,modelRequestsOption:Te,models:f,overview:z,recentLogs:v,selectedEndpointLabel:pe,setEndpointFilter:o,setupComplete:he,setupDoneCount:me,status:C,summaryPending:l.isPending,trendOption:ve,ttftOption:ye,tpotOption:Ne}}function Ft(){var o,n;const{t:s}=x(),a=ht(),t=a.dbInfo?se(a.dbInfo.totalBytes??a.dbInfo.sizeBytes):"-",r=se((o=a.dbInfo)==null?void 0:o.memoryRssBytes);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Ie,{actions:e.jsxs(e.Fragment,{children:[e.jsxs(ke,{value:a.endpointFilter,onValueChange:a.setEndpointFilter,children:[e.jsx(Ae,{className:"h-8 w-[168px]",children:e.jsx(De,{})}),e.jsxs(Oe,{children:[e.jsx(k,{value:"all",children:s("dashboard.filters.endpointAll")}),e.jsx(k,{value:"anthropic",children:s("dashboard.filters.endpointAnthropic")}),e.jsx(k,{value:"openai",children:s("dashboard.filters.endpointOpenAI")}),a.customEndpoints.map(l=>e.jsx(k,{value:l.id,children:l.label||l.id},l.id))]})]}),e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>void a.handleRefresh(),disabled:a.isRefreshing,children:[e.jsx(Le,{className:ze("mr-2 h-4 w-4",a.isRefreshing&&"animate-spin"),"aria-hidden":"true"}),a.isRefreshing?s("common.actions.refreshing"):s("common.actions.refresh")]})]})}),a.isBootstrapping?e.jsx(Ue,{}):a.bootstrapError?e.jsx(M,{icon:e.jsx(Re,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:a.bootstrapError,action:e.jsx(R,{variant:"outline",onClick:()=>void a.handleRefresh(),children:s("common.actions.refresh")})}):e.jsxs(e.Fragment,{children:[a.setupComplete?null:e.jsx(ot,{endpointCount:a.customEndpoints.length,providerCount:((n=a.status)==null?void 0:n.providers)??0}),e.jsx(We,{status:a.status}),e.jsx(Je,{overview:a.overview}),a.setupComplete?null:e.jsx(rt,{doneCount:a.setupDoneCount,total:ct}),e.jsx(et,{empty:!a.daily.length,loading:a.summaryPending,option:a.trendOption}),e.jsx(tt,{daily:a.daily,models:a.models}),e.jsx(st,{modelRequestsOption:a.modelRequestsOption,models:a.models,ttftOption:a.ttftOption,tpotOption:a.tpotOption}),e.jsx(at,{dbInfo:a.dbInfo,dbSizeDisplay:t,memoryDisplay:r,status:a.status}),e.jsx(it,{records:a.recentLogs,loading:a.summaryPending}),a.attentionEvents.length>0?e.jsx(Xe,{connected:a.liveConnected,failed:a.liveFailed,events:a.attentionEvents}):e.jsx(Ze,{connected:a.liveConnected,failed:a.liveFailed})]})]})}export{Ft as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r,j as s,as as g}from"./vendor-D2wC0h2o.js";import{l as u,o as n,D as d,m as y,n as l,x as N,O as i}from"./radix-B9EIjzyN.js";import{c as o}from"./global-CJOj9WGx.js";const k=u,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(l,{ref:x,className:o("fixed left-[50%] top-[50%] z-50 flex max-h-[85vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-xl border border-border bg-background p-6 shadow-[var(--surface-shadow-lg)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",a),...t,children:[e,s.jsxs(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(g,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));p.displayName=l.displayName;const m=({className:a,...e})=>s.jsx("div",{className:o("flex shrink-0 flex-col space-y-1.5 text-center sm:text-left",a),...e});m.displayName="DialogHeader";const f=({className:a,...e})=>s.jsx("div",{className:o("flex shrink-0 flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...e});f.displayName="DialogFooter";const j=r.forwardRef(({className:a,...e},t)=>s.jsx(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(d,{ref:t,className:o("text-sm leading-6 text-muted-foreground",a),...e}));D.displayName=d.displayName;function R({children:a,className:e,...t}){return s.jsx(p,{className:o("gap-0 overflow-hidden p-0",e),...t,children:a})}function A({children:a,className:e}){return s.jsx("div",{className:o("border-b border-border bg-secondary/40 px-6 py-5",e),children:s.jsx(m,{children:a})})}function C({children:a,className:e}){return s.jsx("div",{className:o("min-h-0 overflow-y-auto px-6 py-5",e),children:a})}function z({children:a,className:e}){return s.jsx(f,{className:o("border-t border-border bg-secondary/40 px-6 py-4",e),children:a})}export{R as A,k as D,A as a,j as b,D as c,C as d,z as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as c,j as e,av as J,Z as U,T as Z,aw as _,ao as H,ap as W}from"./vendor-D2wC0h2o.js";import{L as X}from"./router-CUBM_FND.js";import{P as Y}from"./PageToolbar-BnDacS2l.js";import{P as ee}from"./PageSection-Bv6dZZwN.js";import{P as se,a as B}from"./PageState-U6DpaNu4.js";import{a as te,c as q,B as x,q as K}from"./app-BnQl39hq.js";import{u as ae}from"./useEventStream-CQTreYBE.js";import{c as S}from"./global-CJOj9WGx.js";import{i as re,u as G}from"./i18n-Dp-o1LhZ.js";import{B as y}from"./badge-RZTsODn-.js";import{C as ne,a as le}from"./card-DhuLMeO9.js";import{D as oe}from"./disclosure-CJdf1-ap.js";import{M as b}from"./metric-card-B_6litu2.js";import{S as ie}from"./segmented-control-D80bc13p.js";import{S as ce,a as de,b as ue,c as me,d as Q}from"./select-BTwqvh0l.js";import"./query-DVc6ZTRQ.js";import"./radix-B9EIjzyN.js";function xe(s){const r=Date.now()-s,l=Math.abs(r),o=60*1e3,f=60*o,d=24*f,m=new Intl.RelativeTimeFormat(re.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 p=Math.round(l/d);return m.format(r>=0?-p:p,"day")}function fe(s){return new Date(s).toLocaleString()}const ve={info:"secondary",warn:"outline",error:"destructive"};function Ie(){var z,k,I,R,V,F,D;const{t:s}=G(),{pushToast:n}=te(),[r,l]=c.useState(null),[o,f]=c.useState(""),[d,m]=c.useState(""),p=c.useMemo(()=>({limit:50,cursor:r??void 0,level:o||void 0,type:d||void 0}),[r,o,d]),a=q(K.events.list(p),{url:"/api/events",method:"GET",params:p}),u=q(K.events.stats(),{url:"/api/events/stats",method:"GET"},{refetchInterval:15e3}),T=((z=u.data)==null?void 0:z.error)??0,E=((k=u.data)==null?void 0:k.warn)??0,L=((I=u.data)==null?void 0:I.info)??0,M=((R=u.data)==null?void 0:R.total)??0,i=ae({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 A=()=>{l(null),f(""),m("")},h=((V=a.data)==null?void 0:V.events)??[],P=((F=a.data)==null?void 0:F.nextCursor)??null,O=a.isLoading,w=c.useMemo(()=>{if(r!==null)return h;const t=new Set;return[...i.events,...h].filter(v=>t.has(v.id)?!1:(t.add(v.id),!0)).slice(0,50)},[r,i.events,h]),$=c.useMemo(()=>{const t=new Set;return h.forEach(v=>t.add(v.type)),i.events.forEach(v=>t.add(v.type)),Array.from(t).sort()},[h,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(Y,{info:w.length>0?e.jsxs("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:[w.length," events"]}):null,status:r===null?e.jsxs("span",{className:S("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:S("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(x,{variant:"outline",size:"sm",disabled:!r,onClick:()=>l(null),children:[e.jsx(J,{className:"mr-1 h-4 w-4","aria-hidden":"true"}),s("events.actions.newest")]}),e.jsxs(x,{variant:"outline",size:"sm",disabled:!P,onClick:()=>l(P),children:[s("events.actions.older"),e.jsx(U,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]})]})}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"events-stats-grid",children:[e.jsx(b,{size:"sm",dotClassName:"bg-destructive",label:s("events.levels.error"),value:T.toLocaleString(),rawValue:T,valueTestId:"events-stat-error"}),e.jsx(b,{size:"sm",dotClassName:"bg-warning",label:s("events.levels.warn"),value:E.toLocaleString(),rawValue:E,valueTestId:"events-stat-warn"}),e.jsx(b,{size:"sm",dotClassName:"bg-muted-foreground",label:s("events.levels.info"),value:L.toLocaleString(),rawValue:L,valueTestId:"events-stat-info"}),e.jsx(b,{size:"sm",dotClassName:"bg-foreground",label:s("events.stats.total"),value:M.toLocaleString(),rawValue:M,valueTestId:"events-stat-total"})]}),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(ie,{value:o,onChange:t=>{l(null),f(t)},options:[{value:"",label:s("events.filters.allLevels")},{value:"info",label:s("events.levels.info")},{value:"warn",label:s("events.levels.warn")},{value:"error",label:s("events.levels.error")}],"aria-label":s("events.filters.title")}),e.jsxs(ce,{value:d||"all",onValueChange:t=>{l(null),m(t==="all"?"":t)},children:[e.jsx(de,{className:"h-8 w-full md:w-[200px]",children:e.jsx(ue,{})}),e.jsxs(me,{children:[e.jsx(Q,{value:"all",children:s("events.filters.allTypes")}),$.map(t=>e.jsx(Q,{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:A,className:"h-8 px-3 text-xs",children:s("common.actions.reset")})]}):null]}),e.jsx(ee,{title:s("events.title"),description:s(r?"events.actions.older":"events.actions.newest"),children:O?e.jsx(se,{label:s("common.loading")}):a.isError?e.jsx(B,{icon:e.jsx(Z,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:s("events.toast.loadFailure",{message:((D=a.error)==null?void 0:D.message)??s("common.unknownError")}),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:s("common.actions.refresh")})}):w.length===0?e.jsx(B,{icon:e.jsx(_,{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:A,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(H,{initial:!1,children:w.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 pe({event:s}){const{t:n}=G(),r=s.level==="error"?"border-l-error":s.level==="warn"?"border-l-warning":"border-l-success";return e.jsx(ne,{className:S("overflow-hidden border-l-2 hover:bg-muted/30",r),children:e.jsxs(le,{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:ve[s.level]||"secondary",className:"rounded-full text-[10px]",children:n(`events.levels.${s.level}`)}),e.jsxs(y,{variant:"outline",className:"rounded-full text-[10px]",children:["#",s.id]}),s.mode?e.jsx(y,{variant:"secondary",className:"rounded-full text-[10px]",children:s.mode}):null,s.endpoint?e.jsx(y,{variant:"outline",className:"rounded-full text-[10px]",children:s.endpoint}):null]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-[-0.01em]",children:s.title||n("events.defaultTitle")}),e.jsx("p",{className:"mt-1 line-clamp-2 text-sm leading-5 text-muted-foreground",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",{children:fe(s.createdAt)}),e.jsx("p",{children:xe(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(oe,{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-primary hover:text-primary",contentClassName:"mt-2.5",children:e.jsx("pre",{className:"overflow-x-auto rounded-lg bg-secondary p-3 text-xs leading-6",children:JSON.stringify(s.details,null,2)})}):null]})})}function j({label:s,value:n}){return n?e.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border/60 bg-secondary/55 px-2.5 py-1 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"font-medium",children:[s,":"]}),e.jsx("span",{className:"truncate text-foreground",title:n,children:n})]}):null}export{Ie as default};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as u,j as e}from"./vendor-D2wC0h2o.js";import{P as g}from"./PageToolbar-BnDacS2l.js";import{P as o}from"./PageSection-Bv6dZZwN.js";import{c as j}from"./clipboard-BnAnBk_-.js";import{c as x}from"./global-CJOj9WGx.js";import{B as b}from"./app-BnQl39hq.js";import{u as h}from"./i18n-Dp-o1LhZ.js";import"./card-DhuLMeO9.js";import"./query-DVc6ZTRQ.js";import"./router-CUBM_FND.js";import"./radix-B9EIjzyN.js";function E(){const{t}=h(),s=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}),n=u.useMemo(()=>[...s.map(l=>({id:l.id,title:l.title})),{id:"faq",title:t("help.faq.title")}],[s,t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{info:e.jsx("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:t("help.meta.guides",{count:s.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:n.map(l=>e.jsx("li",{children:e.jsx("a",{href:`#help-${l.id}`,className:"block truncate rounded-md px-2 py-1.5 text-muted-foreground transition hover:bg-accent hover:text-foreground",children:l.title})},l.id))})]})}),e.jsxs("div",{className:"min-w-0 space-y-5",children:[e.jsx("div",{id:"help-tour",children:e.jsx(o,{title:s[0].title,children:e.jsx(c,{items:s[0].items,compact:!0})})}),e.jsx("div",{id:"help-configuration",children:e.jsx(o,{title:s[1].title,children:e.jsx(c,{items:s[1].items})})}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsx(o,{title:s[2].title,description:t("help.meta.claudeWorkflow"),children:e.jsx(c,{items:s[2].items})})}),e.jsx("div",{id:"help-codex",children:e.jsx(o,{title:s[3].title,description:t("help.meta.codexWorkflow"),children:e.jsx(c,{items:s[3].items})})})]}),e.jsx("div",{id:"help-usage",children:e.jsx(o,{title:s[4].title,children:e.jsx(c,{items:s[4].items})})}),e.jsx("div",{id:"help-tips",children:e.jsx(o,{title:s[5].title,children:e.jsx(c,{items:s[5].items})})}),e.jsx("div",{id:"help-faq",children:e.jsx(o,{title:t("help.faq.title"),children:e.jsx(y,{items:i})})})]})]})]})}function c({items:t,compact:s=!1}){return e.jsx("ol",{className:x("flex flex-col",s?"gap-2":"gap-2.5"),children:t.map((i,n)=>e.jsxs("li",{className:x("flex gap-3 rounded-lg border border-border/50 bg-card",s?"p-3":"p-3.5"),children:[e.jsx("span",{className:x("flex shrink-0 items-center justify-center rounded-md bg-primary text-xs font-semibold text-primary-foreground",s?"h-6 w-6 text-[11px]":"h-7 w-7"),children:n+1}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-muted-foreground",children:e.jsx(f,{content:i})})]},`${n}-${i}`))})}function f({content:t}){const{t:s}=h(),i=t.split("```");return e.jsx("div",{className:"space-y-3",children:i.map((n,l)=>{if(!n.trim())return null;if(l%2===1){const[a,...m]=n.split(`
|
|
2
|
-
`),r=m.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:a||"bash"}),e.jsx(b,{variant:"ghost",size:"sm",className:"h-6 rounded px-2 text-[11px] text-muted-foreground hover:text-foreground",onClick:()=>j(r),children:s("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:r})})]},l)}return e.jsx(N,{content:n},l)})})}function N({content:t}){const s=t.split(`
|
|
4
|
-
`).map(r=>r.trimEnd()).filter(r=>r.trim().length>0);if(s.length===0)return null;const i=s.filter(r=>/^[-•*]\s+/.test(r.trim())),n=s.filter(r=>/^\d+[).]\s+/.test(r.trim())),l=s.filter(r=>!/^([-•*]|\d+[).])\s+/.test(r.trim())),a=i.map(r=>r.replace(/^[-•*]\s+/,"")),m=n.map(r=>{const d=r.trim().match(/^(\d+)[).]\s+(.*)$/);return{index:(d==null?void 0:d[1])??"",text:(d==null?void 0:d[2])??r.trim()}});return e.jsxs("div",{className:"space-y-2",children:[l.length>0?e.jsx("div",{className:"space-y-1.5",children:l.map((r,d)=>e.jsx("p",{className:"leading-6",children:p(r)},`${r}-${d}`))}):null,a.length>0?e.jsx("ul",{className:"space-y-1.5 rounded-md bg-secondary px-3 py-2",children:a.map((r,d)=>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-primary"}),e.jsx("span",{children:p(r)})]},`${r}-${d}`))}):null,m.length>0?e.jsx("ol",{className:"space-y-1.5 rounded-md bg-secondary px-3 py-2",children:m.map(r=>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 rounded-full bg-primary/15 px-1.5 text-[11px] font-semibold text-primary",children:r.index}),e.jsx("span",{children:p(r.text)})]},`${r.index}-${r.text}`))}):null]})}function p(t){return t.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).map((i,n)=>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)},n):i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:i.slice(2,-2)},n):e.jsx("span",{children:i},n))}function y({items:t}){return t.length===0?null:e.jsx("dl",{className:"space-y-2",children:t.map((s,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:s.q}),e.jsx("span",{className:"rounded-full bg-secondary px-2 py-0.5 text-[11px] text-muted-foreground transition group-open:bg-primary/10 group-open:text-primary",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:s.a})})})]},s.q))})}export{E as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as n,j as e,aZ as S,a_ as E}from"./vendor-D2wC0h2o.js";import{j as k,L as F,B as L}from"./app-BnQl39hq.js";import{C as j,a as N,b as P,d as T,e as A,f as B}from"./card-DhuLMeO9.js";import{L as b,I as y}from"./label-Da-JMxO2.js";import{u as D}from"./i18n-Dp-o1LhZ.js";import{u as G,a as I}from"./router-CUBM_FND.js";import"./global-CJOj9WGx.js";import"./query-DVc6ZTRQ.js";import"./radix-B9EIjzyN.js";function J(){const{t:s}=D(),a=G(),l=I(),{authEnabled:o,isAuthenticated:u,loading:d,login:v,error:x}=k(),[i,p]=n.useState({username:"",password:""}),[h,m]=n.useState(null),[f,g]=n.useState(!1),c=n.useMemo(()=>{var r;const t=l.state;return((r=t==null?void 0:t.from)==null?void 0:r.pathname)??"/"},[l.state]);n.useEffect(()=>{if(!o&&!d){a(c,{replace:!0});return}o&&u&&!d&&a(c,{replace:!0})},[o,c,u,d,a]);const C=async t=>{if(t.preventDefault(),m(null),!i.username.trim()||!i.password){m(s("login.validation.required"));return}g(!0);try{await v(i.username.trim(),i.password),a(c,{replace:!0})}catch(r){m(r instanceof Error?r.message:s("login.validation.failed"))}finally{g(!1)}};return d?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsx(j,{className:"w-full max-w-md",children:e.jsx(N,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(F,{})})})}):o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4 py-10",children:e.jsxs("div",{className:"mx-auto grid w-full max-w-5xl items-center gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(400px,0.8fr)]",children:[e.jsx("div",{className:"hidden lg:block",children:e.jsxs("div",{className:"max-w-lg space-y-6",children:[e.jsx("div",{className:"inline-flex items-center gap-1.5 rounded-lg bg-primary/10 px-3 py-1 text-xs font-semibold text-primary",children:"Secure Gateway Control"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-foreground",children:s("login.title")}),e.jsx("p",{className:"max-w-md text-base leading-7 text-muted-foreground",children:s("login.description")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(w,{icon:e.jsx(S,{className:"h-5 w-5","aria-hidden":"true"}),title:s("login.hint"),description:s("about.support.tip")}),e.jsx(w,{icon:e.jsx(E,{className:"h-5 w-5","aria-hidden":"true"}),title:"Session protected",description:s("help.note")})]})]})}),e.jsxs(j,{className:"w-full",children:[e.jsxs(P,{className:"pb-4 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground",children:"GW"}),e.jsx(T,{className:"text-xl",children:s("login.title")}),e.jsx(A,{children:s("login.description")})]}),e.jsx(N,{children:e.jsxs("form",{className:"space-y-4",onSubmit:C,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(y,{id:"username",value:i.username,autoComplete:"username",autoFocus:!0,onChange:t=>p(r=>({...r,username:t.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(y,{id:"password",type:"password",value:i.password,autoComplete:"current-password",onChange:t=>p(r=>({...r,password:t.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),h||x?e.jsx("div",{className:"rounded-lg bg-destructive/10 px-4 py-3 text-sm text-destructive",children:h||x}):null,e.jsx(L,{type:"submit",className:"w-full",disabled:f,children:s(f?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(B,{className:"justify-center pt-2",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})]})}):null}function w({description:s,icon:a,title:l}){return e.jsxs("div",{className:"rounded-lg bg-card px-4 py-4 shadow-[var(--surface-shadow)]",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:a}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-foreground",children:l}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s})]})}export{J as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as x,j as e,o as cs,ar as us,aj as ms,as as ps,ak as De,at as Te,aq as xs,au as gs,Z as fs,T as hs,P as ys}from"./vendor-D2wC0h2o.js";import{P as bs}from"./PageToolbar-BnDacS2l.js";import{c as E}from"./global-CJOj9WGx.js";import{B as R,d as js,a as fe,c as G,q as H,s as P,t as vs,b as A}from"./app-BnQl39hq.js";import{B as V}from"./badge-RZTsODn-.js";import{C as Fe,a as Ke}from"./card-DhuLMeO9.js";import{L as B,I as xe}from"./label-Da-JMxO2.js";import{S as te,a as le,b as ae,c as re,d as $}from"./select-BTwqvh0l.js";import{u as I}from"./i18n-Dp-o1LhZ.js";import{D as ws,A as Ns,a as ks,b as Ss,c as Cs,d as Ls}from"./DialogShell-BbpG8sot.js";import{P as _s,a as Y}from"./PageState-U6DpaNu4.js";import{T as Es,a as Rs,b as Ds,c as Ts}from"./tabs-DYNHHISl.js";import{c as Fs}from"./clipboard-BnAnBk_-.js";import{a as Ks,g as he,b as Me,f as O,c as ye,d as Ms,e as q,h as Pe,i as qe,j as Ps,T as qs}from"./utils-HY2ZFw0f.js";import{P as zs,a as As,b as Os}from"./popover-JpUYyIhi.js";import{S as Is}from"./segmented-control-D80bc13p.js";import{S as $s}from"./switch-CeKtgMDT.js";import{L as ze}from"./router-CUBM_FND.js";import{a as Qs}from"./query-DVc6ZTRQ.js";import{g as _e}from"./gateway-DxCj_uok.js";import"./radix-B9EIjzyN.js";function Us({apiKeys:s,selected:l,onChange:p,disabled:a,className:o}){const{t}=I(),i=x.useId(),[b,h]=x.useState(!1),[d,v]=x.useState(null),y=x.useRef(null),w=x.useRef(null),m=x.useRef(null),N=()=>{const f=w.current;if(!f)return;const j=f.getBoundingClientRect(),S=Math.max(j.width,256),n=window.innerWidth-12;v({left:Math.min(j.left,n-S),top:j.bottom+8,width:S})};x.useEffect(()=>{if(!b)return;const f=S=>{var C,D;const n=S.target;!((C=y.current)!=null&&C.contains(n))&&!((D=m.current)!=null&&D.contains(n))&&h(!1)},j=S=>{var n;S.key==="Escape"&&(h(!1),(n=w.current)==null||n.focus())};return window.addEventListener("mousedown",f),window.addEventListener("keydown",j),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",j)}},[b]),x.useEffect(()=>{if(b)return N(),window.addEventListener("resize",N),window.addEventListener("scroll",N,!0),()=>{window.removeEventListener("resize",N),window.removeEventListener("scroll",N,!0)}},[b]);const r=x.useMemo(()=>{if(l.length===0)return[];const f=new Map;for(const j of s)f.set(j.id,j);return l.map(j=>{const S=f.get(j);return S?S.isWildcard?t("apiKeys.wildcard"):S.name:null}).filter(j=>!!j)},[s,l,t]),g=l.length===0?t("logs.filters.apiKeyAll"):t("logs.filters.apiKeySelected",{count:l.length}),L=f=>{l.includes(f)?p(l.filter(j=>j!==f)):p([...l,f])};return e.jsxs("div",{className:E("relative space-y-2",o),ref:y,children:[e.jsx(B,{htmlFor:i,children:t("logs.filters.apiKey")}),e.jsxs("button",{ref:w,id:i,type:"button",onClick:()=>{N(),h(f=>!f)},disabled:a||s.length===0,title:t("logs.filters.apiKeyHint"),className:E("flex h-10 w-full items-center justify-between rounded-lg border border-input bg-background px-3 text-sm ring-offset-background transition-all focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",l.length>0&&"border-primary",b&&"ring-2 ring-ring ring-offset-2"),children:[e.jsxs("span",{className:"truncate",children:[g,r.length>0&&e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:r.join(", ")})]}),e.jsx("svg",{className:E("h-4 w-4 opacity-50 transition-transform",b&&"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"})})]}),b&&d&&cs.createPortal(e.jsxs("div",{ref:m,className:"fixed z-50 rounded-lg border bg-popover p-2 shadow-[var(--surface-shadow-lg)]",style:d,children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-secondary px-3 py-2 text-xs",children:[e.jsx("span",{children:g}),e.jsx("button",{type:"button",onClick:()=>p([]),disabled:l.length===0,className:"text-primary hover:underline disabled:opacity-40",children:t("common.actions.reset")})]}),e.jsxs("div",{className:"max-h-56 overflow-y-auto py-2",children:[s.map(f=>{const j=f.isWildcard?t("apiKeys.wildcard"):f.name,S=l.includes(f.id);return e.jsxs("label",{className:E("flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2 text-sm transition hover:bg-primary/5",S&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-border",checked:S,onChange:()=>L(f.id)}),e.jsx("span",{className:"truncate",children:j})]},f.id)}),s.length===0&&e.jsx("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:t("logs.filters.apiKeyAll")})]})]}),document.body)]})}function Vs(s){const{t:l}=I(),{activeFilters:p,filtersExpanded:a,setFiltersExpanded:o,handleResetFilters:t,activeQuickView:i,applyQuickView:b,providerFilter:h,setProviderFilter:d,endpointFilter:v,setEndpointFilter:y,selectedApiKeys:w,setSelectedApiKeys:m,modelFilter:N,setModelFilter:r,statusFilter:g,setStatusFilter:L,fromDate:f,setFromDate:j,toDate:S,setToDate:n,providerOptions:C,apiKeys:D,apiKeysLoading:F,customEndpoints:T}=s;return e.jsx(Fe,{"data-testid":"logs-filters-card",className:"overflow-hidden",children:e.jsxs(Ke,{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")}),p.length>0&&e.jsx(V,{variant:"outline",className:"rounded-full border-transparent bg-primary/10 px-2.5 py-0.5 text-[11px] font-semibold text-primary",children:l("common.filters.activeCount",{count:p.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:[p.length>0&&e.jsx(R,{variant:"ghost",size:"sm",onClick:t,className:"h-8 rounded-full px-3 text-xs",children:l("common.actions.reset")}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>o(c=>!c),className:"h-8 rounded-full px-3 text-xs",children:a?e.jsxs(e.Fragment,{children:[l("common.filters.collapse"),e.jsx(us,{className:"ml-1 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:[l("common.filters.expand"),e.jsx(ms,{className:"ml-1 h-4 w-4"})]})})]})]}),e.jsxs("div",{className:"grid gap-2 lg:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx("div",{className:"flex min-h-10 items-center rounded-lg bg-secondary px-3 py-2",children:p.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:p.map(c=>e.jsxs(V,{variant:"outline",role:"button",tabIndex:0,className:"flex cursor-pointer items-center gap-1 rounded-full border border-border bg-card px-2.5 py-1 text-[11px] font-semibold text-foreground/90 transition hover:bg-secondary",onClick:c.onRemove,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c.onRemove())},children:[c.label,e.jsx(ps,{className:"h-3 w-3","aria-hidden":"true"})]},c.key))}):e.jsx("span",{className:"text-xs text-muted-foreground",children:l("common.filters.allRequests")})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 lg:justify-end",children:[e.jsx(ge,{label:l("logs.filters.apiKey"),value:w.length.toString()}),e.jsx(ge,{label:l("logs.filters.provider"),value:h==="all"?"0":"1"}),e.jsx(ge,{label:l("logs.filters.endpoint"),value:v==="all"?"0":"1"})]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 rounded-lg bg-secondary px-2 py-1.5",children:["all","errors","today","anthropic","openai"].map(c=>e.jsx(R,{variant:"ghost",size:"sm",className:E("h-7 rounded-full px-3 text-[11px] font-semibold transition-colors",i===c?"bg-card text-foreground shadow-[var(--surface-shadow)]":"text-muted-foreground"),onClick:()=>b(c),children:l(`logs.quickViews.${c}`)},c))})]}),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(B,{children:l("logs.filters.provider")}),e.jsxs(te,{value:h,onValueChange:d,children:[e.jsx(le,{children:e.jsx(ae,{})}),e.jsxs(re,{children:[e.jsx($,{value:"all",children:l("logs.filters.providerAll")}),C.map(c=>e.jsx($,{value:c.id,children:c.label??c.id},c.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:l("logs.filters.endpoint")}),e.jsxs(te,{value:v,onValueChange:y,children:[e.jsx(le,{children:e.jsx(ae,{})}),e.jsxs(re,{children:[e.jsx($,{value:"all",children:l("logs.filters.endpointAll")}),e.jsx($,{value:"anthropic",children:l("logs.filters.endpointAnthropic")}),e.jsx($,{value:"openai",children:l("logs.filters.endpointOpenAI")}),T==null?void 0:T.map(c=>e.jsx($,{value:c.id,children:c.label||c.id},c.id))]})]})]}),e.jsx(Us,{className:"md:col-span-2",apiKeys:D,selected:w,disabled:F,onChange:m}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:l("logs.filters.modelId")}),e.jsx(xe,{value:N,onChange:c=>r(c.target.value),placeholder:l("logs.filters.modelPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:l("logs.filters.status")}),e.jsxs(te,{value:g,onValueChange:c=>L(c),children:[e.jsx(le,{children:e.jsx(ae,{})}),e.jsxs(re,{children:[e.jsx($,{value:"all",children:l("logs.filters.statusAll")}),e.jsx($,{value:"success",children:l("logs.filters.statusSuccess")}),e.jsx($,{value:"error",children:l("logs.filters.statusError")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:l("logs.filters.startDate")}),e.jsx(xe,{type:"date",value:f,onChange:c=>j(c.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{children:l("logs.filters.endDate")}),e.jsx(xe,{type:"date",value:S,onChange:c=>n(c.target.value)})]})]})]})})}function ge({label:s,value:l}){return e.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-border/60 bg-card px-2.5 py-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:s}),e.jsx("span",{className:"metric-number font-semibold text-foreground",children:l})]})}const be={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 p=await js.post("/api/logs/export",s,{responseType:"blob",timeout:l});return new Blob([p.data],{type:"application/zip"})}};function Ae({apiKeyMap:s,logId:l,open:p,providerLabelMap:a}){var N;const{t:o}=I(),{pushToast:t}=fe(),i=G(H.logs.detail(l),be.detailRequest(l),{enabled:p&&l!==null,staleTime:3e4,gcTime:15e3,placeholderData:void 0});x.useEffect(()=>{!i.isError||!i.error||t({title:o("logs.detail.loadError"),description:i.error.message,variant:"error"})},[i.error,i.isError,t,o]);const b=x.useCallback(async(r,g,L)=>{if(!g){t({title:o("logs.detail.copy.empty",{label:r}),variant:"info"});return}try{await Fs(g),t({title:o(L),variant:"success"})}catch(f){t({title:o("logs.detail.copy.failure"),description:f instanceof Error?f.message:o("logs.detail.copy.failureFallback"),variant:"error"})}},[t,o]),h=x.useCallback((r,g)=>{if(!g){t({title:o("logs.detail.copy.empty",{label:r}),variant:"info"});return}const L=new Blob([g],{type:"application/json;charset=utf-8"}),f=URL.createObjectURL(L),j=document.createElement("a"),S=new Date().toISOString().replace(/[:.]/g,"-"),n=r.trim().toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]+/gi,"-").replace(/^-+|-+$/g,"")||"payload";j.href=f,j.download=`cc-gw-log-${l??"payload"}-${n}-${S}.json`,document.body.appendChild(j),j.click(),document.body.removeChild(j),URL.revokeObjectURL(f)},[l,t,o]),d=i.data,v=d?a.get(d.provider)??d.provider:"",y=d&&d.api_key_id!=null?s.get(d.api_key_id):void 0,w=d?Ks(d,o):null,m=d?he(d,o):null;return{apiKeyMeta:y,errorSourceMeta:w,errorMessage:i.isError?((N=i.error)==null?void 0:N.message)??null:null,handleCopy:b,handleDownloadPayload:h,isError:i.isError,isPending:i.isPending,providerLabel:v,refetch:i.refetch,record:d,statusMeta:m}}function Hs({open:s,logId:l,onClose:p,providerLabelMap:a,apiKeyMap:o}){var f,j,S;const{t}=I(),{apiKeyMeta:i,errorSourceMeta:b,errorMessage:h,handleCopy:d,handleDownloadPayload:v,isError:y,isPending:w,providerLabel:m,refetch:N,record:r,statusMeta:g}=Ae({apiKeyMap:o,logId:l,open:s,providerLabelMap:a}),L=x.useMemo(()=>{var C,D,F,T;return r?[{key:"client-request",title:t("logs.detail.payload.clientRequest"),value:((C=r.payload)==null?void 0:C.client_request)??null,emptyLabel:t("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"},...(D=r.payload)!=null&&D.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"}]:[],...(F=r.payload)!=null&&F.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:((T=r.payload)==null?void 0:T.client_response)??null,emptyLabel:t("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}].map(c=>({...c,display:Me(c.value,c.emptyLabel)})):[]},[r,t]);return e.jsx(ws,{open:s,onOpenChange:n=>{n||p()},children:e.jsxs(Ns,{className:"w-[min(96vw,1200px)] max-w-[1200px]",children:[e.jsxs(ks,{className:"pr-14",children:[e.jsx(Ss,{children:t("logs.detail.title")}),e.jsx(Cs,{children:r?t("logs.detail.id",{id:r.id}):t("logs.detail.loadError")})]}),e.jsx(Ls,{className:"max-h-[78vh]",children:w?e.jsx(_s,{compact:!0,className:"min-h-[240px]",label:t("common.loading")}):y?e.jsx(Y,{compact:!0,className:"min-h-[240px]",tone:"danger",title:t("logs.detail.loadError"),description:h??t("common.unknownError"),action:e.jsx(R,{variant:"outline",onClick:()=>void N(),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.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border bg-secondary p-3 text-xs",children:[e.jsx("span",{className:"font-medium",children:t("logs.detail.summary.route",{from:r.client_model??t("logs.detail.info.noRequestedModel"),to:r.model})}),e.jsx("span",{className:"text-muted-foreground",children:t("logs.detail.summary.latency",{value:O(r.latency_ms,t("common.units.ms"))})}),r.ttft_ms!==null?e.jsxs("span",{className:"text-muted-foreground",children:["TTFT: ",O(r.ttft_ms,t("common.units.ms"))]}):null]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(V,{variant:g==null?void 0:g.variant,children:(g==null?void 0:g.label)??"-"}),e.jsx(V,{variant:"outline",children:r.stream?t("logs.stream.streaming"):t("logs.stream.single")})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-5",children:[e.jsx(U,{label:t("logs.detail.info.latency"),value:O(r.latency_ms,t("common.units.ms"))}),e.jsx(U,{label:t("logs.detail.info.ttft"),value:O(r.ttft_ms,t("common.units.ms"))}),e.jsx(U,{label:t("logs.detail.info.tpot"),value:O(r.tpot_ms,t("common.units.msPerToken"))}),e.jsx(U,{label:t("logs.detail.info.status"),value:(g==null?void 0:g.label)??"-"}),e.jsx(U,{label:t("logs.detail.info.errorSource"),value:(b==null?void 0:b.label)??"-"})]}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsx(M,{label:t("logs.detail.info.time"),value:ye(r.timestamp)}),e.jsx(M,{label:t("logs.detail.info.sessionId"),value:r.session_id??"-"}),e.jsx(M,{label:t("logs.detail.info.endpoint"),value:r.endpoint||"-"}),e.jsx(M,{label:t("logs.detail.info.provider"),value:m}),e.jsx(M,{label:t("logs.detail.info.requestedModel"),value:r.client_model??t("logs.detail.info.noRequestedModel")}),e.jsx(M,{label:t("logs.detail.info.model"),value:r.model}),e.jsx(M,{label:t("logs.detail.info.stream"),value:Ms(r.stream)}),e.jsx(M,{label:t("logs.detail.info.status"),value:(g==null?void 0:g.label)??"-"}),e.jsx(M,{label:t("logs.detail.info.errorSource"),value:(b==null?void 0:b.label)??"-"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(U,{label:t("logs.detail.info.inputTokens"),value:q(r.input_tokens)}),e.jsx(U,{label:t("logs.detail.info.cacheReadTokens"),value:q(r.cache_read_tokens)}),e.jsx(U,{label:t("logs.detail.info.cacheCreationTokens"),value:q(r.cache_creation_tokens)}),e.jsx(U,{label:t("logs.detail.info.outputTokens"),value:q(r.output_tokens)})]}),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]}),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(M,{label:t("logs.detail.apiKey.name"),value:r.api_key_id==null&&!r.api_key_name?t("logs.detail.apiKey.missing"):i!=null&&i.isWildcard?t("apiKeys.wildcard"):(i==null?void 0:i.name)??r.api_key_name??t("logs.detail.apiKey.missing")}),e.jsx(M,{label:t("logs.detail.apiKey.identifier"),value:r.api_key_id??t("common.noData")}),e.jsx(M,{label:t("logs.detail.apiKey.masked"),value:i!=null&&i.isWildcard?t("apiKeys.wildcard"):(i==null?void 0:i.maskedKey)??r.api_key_name??t("logs.detail.apiKey.maskedUnavailable")}),e.jsx(M,{label:t("logs.detail.apiKey.lastUsed"),value:i!=null&&i.lastUsedAt?new Date(i.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||(j=r.payload)!=null&&j.upstream_response?t("logs.detail.payload.helperWithUpstream"):t("logs.detail.payload.helperClientOnly")})]}),e.jsxs(Es,{defaultValue:(S=L[0])==null?void 0:S.key,children:[e.jsx(Rs,{className:"w-full justify-start overflow-x-auto",children:L.map(n=>e.jsx(Ds,{value:n.key,children:n.title},n.key))}),L.map(n=>e.jsx(Ts,{value:n.key,children:e.jsx(Bs,{title:n.title,display:n.display,onCopy:()=>d(n.title,n.value,n.copyToast),onDownload:()=>v(n.title,n.value),panelKey:n.key,t})},n.key))]})]})]})]}):e.jsx(Y,{compact:!0,className:"min-h-[240px]",title:t("logs.detail.loadError"),description:t("common.noData")})})]})})}function U({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 M({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 Bs({display:s,onCopy:l,onDownload:p,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(R,{variant:"outline",size:"sm",onClick:l,children:[e.jsx(De,{className:"mr-2 h-3.5 w-3.5"}),t("common.actions.copy")]}),e.jsxs(R,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(Te,{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})]})}const X=[20,50,100],J=["endpoint","provider","requestedModel","routedModel","apiKey","tokens","duration","status","error"],oe=["endpoint","provider","requestedModel","routedModel","apiKey","tokens","duration","status","error"];function Ws(){return typeof window>"u"?"comfortable":window.localStorage.getItem(P.logs.density)==="compact"?"compact":"comfortable"}function Gs(){if(typeof window>"u")return X[0];const s=window.localStorage.getItem(P.logs.pageSize),l=Number(s);return X.includes(l)?l:X[0]}function Ee(s,l=!1){if(!s)return;const p=l?`${s}T23:59:59.999`:`${s}T00:00:00.000`,a=Date.parse(p);return Number.isFinite(a)?a:void 0}function Js(s,l,p){return s===p&&l===p}function Xs({autoRefresh:s,columnOptions:l,exporting:p,onExport:a,onRefresh:o,onResetColumns:t,onSetDensity:i,onToggleAutoRefresh:b,onToggleColumn:h,refreshing:d,rowDensity:v,visibleColumns:y,visibleColumnSet:w}){const{t:m}=I(),N=JSON.stringify(y)===JSON.stringify(J);return e.jsxs("div",{className:"flex w-full flex-col gap-3 xl:w-auto xl:flex-row xl:items-center",children:[e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center xl:w-auto xl:flex-nowrap",children:[e.jsx(Is,{block:!0,className:"w-full overflow-x-auto sm:w-auto",value:v,onChange:i,options:[{value:"comfortable",label:m("logs.table.density.comfortable")},{value:"compact",label:m("logs.table.density.compact")}]}),e.jsxs(zs,{children:[e.jsx(As,{asChild:!0,children:e.jsx(R,{variant:"outline",size:"sm",className:"w-full sm:w-auto",children:m("logs.actions.columns")})}),e.jsxs(Os,{align:"end",className:"w-64 p-3",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:m("logs.actions.columns")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("logs.actions.visibleCount",{count:y.length})})]}),e.jsx(R,{variant:"ghost",size:"sm",onClick:t,disabled:N,children:m("common.actions.reset")})]}),e.jsx("div",{className:"grid gap-1.5",children:l.map(r=>{const g=w.has(r.id);return e.jsxs("label",{className:E("flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2 text-sm transition hover:bg-accent",g&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",checked:g,onChange:()=>h(r.id),className:"h-4 w-4 rounded border-border"}),e.jsx("span",{children:r.label})]},r.id)})})]})]}),e.jsxs(R,{onClick:a,disabled:p,className:"w-full sm:w-auto",children:[e.jsx(Te,{className:"mr-2 h-4 w-4"}),m(p?"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($s,{checked:s,onCheckedChange:b,"aria-label":m("logs.actions.autoRefresh")}),m("logs.actions.autoRefresh")]}),e.jsxs(R,{variant:"outline",size:"sm",onClick:o,disabled:d,className:"shrink-0",children:[e.jsx(xs,{className:E("mr-2 h-4 w-4",d&&"animate-spin")}),m(d?"common.actions.refreshing":"logs.actions.manualRefresh")]})]})]})}function Ys({record:s,providerLabelMap:l,onSelect:p}){const{t:a}=I(),o=he(s,a),t=l.get(s.provider)??s.provider,i=Pe(s.session_id),b=i==null?void 0:i.accentStyle;return e.jsxs("button",{type:"button","data-session-id":i==null?void 0:i.sessionId,"data-session-color":i==null?void 0:i.colorKey,style:b,onClick:()=>p(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:ye(s.timestamp)}),e.jsx(V,{variant:o.variant,className:"text-xs",children:o.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:t,children:t}),e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",title:s.model,children:s.model})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs tabular-nums text-muted-foreground",children:[e.jsx("span",{children:O(s.latency_ms,a("common.units.ms"))}),s.ttft_ms!=null?e.jsxs("span",{children:[a("logs.table.columns.latencyTtft")," ",q(s.ttft_ms)]}):null]})]})}const Re={accent:"bg-primary",ok:"bg-success",warn:"bg-warning",error:"bg-destructive"};function Zs({logId:s,providerLabelMap:l,apiKeyMap:p}){const{t:a}=I(),{record:o,isPending:t,isError:i,errorMessage:b,statusMeta:h,providerLabel:d,handleCopy:v,refetch:y}=Ae({apiKeyMap:p,logId:s,open:!0,providerLabelMap:l}),w=x.useMemo(()=>{var C,D,F,T;if(!o)return[];const n=[{key:"client-request",title:a("logs.detail.payload.clientRequest"),value:((C=o.payload)==null?void 0:C.client_request)??null,emptyLabel:a("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"}];return(D=o.payload)!=null&&D.upstream_request&&n.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"}),(F=o.payload)!=null&&F.upstream_response&&n.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"}),n.push({key:"client-response",title:a("logs.detail.payload.clientResponse"),value:((T=o.payload)==null?void 0:T.client_response)??null,emptyLabel:a("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}),n.map(c=>({...c,display:Me(c.value,c.emptyLabel)}))},[o,a]),[m,N]=x.useState("client-request"),r=w.find(n=>n.key===m)??w[0];if(t)return e.jsx("div",{className:"py-3",children:e.jsx(qe,{className:"h-28 w-full"})});if(i)return e.jsx(Y,{compact:!0,tone:"danger",title:a("logs.detail.loadError"),description:b??a("common.unknownError"),action:e.jsx(R,{variant:"outline",size:"sm",onClick:()=>void y(),children:a("common.actions.refresh")})});if(!o)return e.jsx(Y,{compact:!0,title:a("logs.detail.loadError"),description:a("common.noData")});const g=Ps(o,d,a),L=a("common.units.ms"),f=[{label:a("logs.detail.info.status"),value:(h==null?void 0:h.label)??"-"},{label:a("logs.detail.info.latency"),value:O(o.latency_ms,L)},{label:a("logs.detail.info.ttft"),value:O(o.ttft_ms,L)},{label:a("logs.detail.info.inputTokens"),value:q(o.input_tokens)},{label:a("logs.detail.info.outputTokens"),value:q(o.output_tokens)},{label:a("logs.detail.info.cacheReadTokens"),value:q(o.cache_read_tokens)}],j=o.ttft_ms!=null,S=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:g.map((n,C)=>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:E("mt-1 h-[9px] w-[9px] rounded-full",Re[n.tone])}),C<g.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:n.title}),n.atLabel?e.jsx("span",{className:"text-[10.5px] tabular-nums text-muted-foreground",children:n.atLabel}):null,n.durLabel?e.jsx("span",{className:"ml-auto text-[10.5px] tabular-nums text-muted-foreground",children:n.durLabel}):null]}),n.detail?e.jsx("div",{className:"mt-1 text-[11px] leading-[1.55] text-muted-foreground",children:n.detail}):null,e.jsx("div",{className:"mt-1.5 h-1 w-full max-w-[220px] bg-secondary",children:e.jsx("div",{className:E("h-full",Re[n.tone]),style:{width:`${n.barPct}%`}})})]})]},n.id))}),j?null:e.jsx("p",{className:"mt-1 text-[10.5px] text-muted-foreground/70",children:a("logs.detail.trace.degraded")})]}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[e.jsx("div",{className:"grid grid-cols-3 gap-2",children:f.map(n=>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:n.label}),e.jsx("div",{className:"mt-0.5 text-[13px] font-semibold tabular-nums",children:n.value})]},n.label))}),e.jsxs("div",{className:"border border-border bg-card",children:[e.jsx("div",{className:"flex gap-0.5 border-b border-border bg-secondary/50 p-1.5",role:"tablist",children:w.map(n=>{const C=n.key===(r==null?void 0:r.key);return e.jsx("button",{type:"button",role:"tab","aria-selected":C,onClick:()=>N(n.key),className:E("px-2.5 py-1 text-[10.5px] font-medium transition-colors",C?"bg-card text-foreground":"text-muted-foreground hover:text-foreground"),children:n.title},n.key)})}),e.jsx("pre",{"data-testid":`log-payload-${(r==null?void 0:r.key)??"none"}`,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:(r==null?void 0:r.display.text)||a("logs.detail.payload.emptyRequest")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(R,{variant:"outline",size:"sm",className:"h-[30px] flex-1",onClick:()=>{r&&v(r.title,r.value,r.copyToast)},children:[e.jsx(De,{className:"mr-1.5 h-3.5 w-3.5","aria-hidden":"true"}),a("logs.detail.inline.copyRequest")]}),S?e.jsx(R,{variant:"outline",size:"sm",className:"h-[30px] flex-1",onClick:()=>v(a("logs.detail.inline.copySession"),S,"logs.detail.inline.sessionCopied"),children:a("logs.detail.inline.copySession")}):null,e.jsx(R,{asChild:!0,variant:"outline",size:"sm",className:"h-[30px] flex-1",children:e.jsxs(ze,{to:"/providers?tab=routing",children:[a("logs.detail.inline.viewRule"),e.jsx(gs,{className:"ml-1.5 h-3.5 w-3.5","aria-hidden":"true"})]})})]})]})]})}function et({record:s,providerLabelMap:l,apiKeyMap:p,onSelect:a,isExpanded:o,onToggleExpand:t,isEven:i,density:b,visibleColumnSet:h}){const{t:d}=I(),v=l.get(s.provider)??s.provider,y=s.endpoint||"-",w=he(s,d),m=s.client_model??d("logs.table.requestedModelFallback"),N=s.api_key_id!=null?p.get(s.api_key_id):void 0,r=s.api_key_id==null?d("logs.table.apiKeyUnknown"):N!=null&&N.isWildcard?d("apiKeys.wildcard"):N!=null&&N.name?N.name:s.api_key_name?s.api_key_name:d("logs.table.apiKeyUnknown"),g=b==="compact"?"px-3 py-1.5":"px-3 py-2",L=i?"bg-muted/30":"bg-background",f=Pe(s.session_id),j=f==null?void 0:f.accentStyle,S=h.size+2,n=d(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":f==null?void 0:f.sessionId,"data-session-color":f==null?void 0:f.colorKey,className:E("transition-colors duration-160 ease-surface",i?"bg-muted/30":"",o?"bg-muted/50":"hover:bg-muted/50"),children:[e.jsx("td",{className:E("sticky left-0 z-10 text-xs",g,L),style:j,children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button","aria-expanded":o,"aria-label":n,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(fs,{className:E("h-3.5 w-3.5 transition-transform duration-160 ease-surface",o&&"rotate-90"),"aria-hidden":"true"})}),e.jsx("span",{className:"metric-number",children:ye(s.timestamp)})]})}),h.has("endpoint")&&e.jsx("td",{className:E(g,"text-xs"),children:y}),h.has("provider")&&e.jsx("td",{className:E(g,"text-xs"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:v,children:v})}),h.has("requestedModel")&&e.jsx("td",{className:E(g,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:m,children:m})}),h.has("routedModel")&&e.jsx("td",{className:E(g,"text-xs"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:s.model,children:s.model})}),h.has("apiKey")&&e.jsx("td",{className:E(g,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[90px] truncate",title:r,children:r})}),h.has("tokens")&&e.jsx("td",{className:E(g,"text-right text-xs tabular-nums align-top"),children:e.jsxs("span",{className:"inline-flex flex-col items-end gap-0.5",children:[e.jsxs("span",{className:"whitespace-nowrap",children:[d("logs.table.columns.tokenIn")," ",q(s.input_tokens),e.jsx("span",{className:"mx-1 text-muted-foreground/50",children:"·"}),d("logs.table.columns.tokenOut")," ",q(s.output_tokens)]}),(()=>{const C=(s.cache_read_tokens??0)+(s.cache_creation_tokens??0);return C>0?e.jsxs("span",{className:"whitespace-nowrap text-[11px] text-muted-foreground/70",children:[d("logs.table.columns.tokenCache")," ",q(C)]}):null})()]})}),h.has("duration")&&e.jsx("td",{className:E(g,"text-right text-xs tabular-nums align-top"),children:e.jsxs("span",{className:"inline-flex flex-col items-end gap-0.5",children:[e.jsx("span",{className:"whitespace-nowrap",children:O(s.latency_ms,"ms")}),(s.ttft_ms!=null||s.tpot_ms!=null)&&e.jsxs("span",{className:"whitespace-nowrap text-[11px] text-muted-foreground/70",title:`${d("logs.table.columns.latencyTtft")} ${O(s.ttft_ms,"ms")} · ${d("logs.table.columns.latencyTpot")} ${O(s.tpot_ms,"ms/tk")}`,children:[d("logs.table.columns.latencyTtft")," ",q(s.ttft_ms),e.jsx("span",{className:"mx-1 text-muted-foreground/50",children:"·"}),d("logs.table.columns.latencyTpot")," ",q(s.tpot_ms)]})]})}),h.has("status")&&e.jsx("td",{className:E(g,"text-center"),children:e.jsx(V,{variant:w.variant,className:"text-xs",children:w.label})}),h.has("error")&&e.jsx("td",{className:E(g,"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:E("sticky right-0 z-10 text-center",g,L),children:e.jsx(R,{variant:"outline",size:"sm",onClick:()=>a(s.id),children:d("logs.actions.detail")})})]}),o?e.jsx("tr",{"data-testid":`log-row-expanded-wrapper-${s.id}`,children:e.jsx("td",{colSpan:S,className:"border-t border-border bg-secondary/30 p-0",children:e.jsx("div",{className:"px-5 pb-5 pt-3",children:e.jsx(Zs,{logId:s.id,providerLabelMap:l,apiKeyMap:p})})})}):null]})}function st(s){const{t:l}=I(),{tableScrollRef:p,visibleColumnSet:a,visibleColumnCount:o,logsError:t,logsPending:i,items:b,activeFiltersCount:h,total:d,handleResetFilters:v,handleRetry:y,providerLabelMap:w,apiKeyMap:m,handleOpenDetail:N,expandedLogId:r,onToggleExpand:g,rowDensity:L,showScrollHint:f,pageSize:j,setPageSize:S,page:n,totalPages:C,setPage:D}=s,F=e.jsx(Y,{compact:!0,tone:"danger",icon:e.jsx(hs,{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(R,{variant:"outline",size:"sm",onClick:y,children:l("common.actions.refresh")}),h>0?e.jsx(R,{variant:"ghost",size:"sm",onClick:v,children:l("common.actions.reset")}):null]})}),T=e.jsx(Y,{compact:!0,tone:"primary",icon:e.jsx(ys,{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(R,{variant:"outline",size:"sm",onClick:v,children:l("logs.empty.actions.reset")}):null,e.jsx(R,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(ze,{to:"/api-keys",children:l("logs.empty.actions.apiKeys")})})]})});return e.jsx(Fe,{className:"overflow-hidden bg-card shadow-[var(--surface-shadow)]",children:e.jsxs(Ke,{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:d.toLocaleString()})}),e.jsx("span",{className:"mx-1.5 text-muted-foreground/50",children:"·"}),l("logs.actions.visibleCount",{count:o-2})]})]}),e.jsxs("div",{className:"hidden md:flex flex-wrap items-center gap-2",children:[e.jsx(V,{variant:"secondary",children:"Wide Table"}),e.jsx(V,{variant:"outline",className:"bg-background",children:l(L==="compact"?"logs.table.density.compact":"logs.table.density.comfortable")}),f?e.jsx(V,{variant:"warning",children:"Scroll for more"}):null]})]}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{ref:p,className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[1180px] text-sm",children:[e.jsx("thead",{className:"border-b border-border/50 bg-secondary/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 z-20 bg-secondary px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.time")}),a.has("endpoint")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.endpoint")}),a.has("provider")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.provider")}),a.has("requestedModel")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.requestedModel")}),a.has("routedModel")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.routedModel")}),a.has("apiKey")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.apiKey")}),a.has("tokens")&&e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.tokens")}),a.has("duration")&&e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.duration")}),a.has("status")&&e.jsx("th",{className:"px-3 py-2.5 text-center text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.status")}),a.has("error")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.error")}),e.jsx("th",{className:"sticky right-0 z-20 bg-secondary px-3 py-2.5 text-center text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:l("logs.table.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-border/50",children:i?Array.from({length:8}).map((c,_)=>e.jsx(qs,{columns:o},_)):t&&b.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:o,className:"px-3 py-6",children:F})}):b.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:o,className:"px-3 py-8 text-center text-sm text-muted-foreground",children:T})}):b.map((c,_)=>e.jsx(et,{record:c,providerLabelMap:w,apiKeyMap:m,onSelect:N,isExpanded:c.id===r,onToggleExpand:g,isEven:_%2===0,density:L,visibleColumnSet:a},c.id))})]})}),f&&e.jsx("div",{className:"table-scroll-hint"})]}),e.jsx("div",{className:"md:hidden",children:i?e.jsx("div",{className:"space-y-3 p-4",children:Array.from({length:5}).map((c,_)=>e.jsx(qe,{className:"h-20 w-full"},_))}):t&&b.length===0?e.jsx("div",{className:"px-3 py-6",children:F}):b.length===0?e.jsx("div",{className:"px-3 py-8",children:T}):b.map(c=>e.jsx(Ys,{record:c,providerLabelMap:w,onSelect:N},c.id))}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 bg-secondary/50 p-4 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-secondary px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:l("logs.table.pagination.perPage")}),e.jsxs(te,{value:j.toString(),onValueChange:c=>S(Number(c)),children:[e.jsx(le,{className:"h-8 w-[80px] bg-background",children:e.jsx(ae,{})}),e.jsx(re,{children:X.map(c=>e.jsx($,{value:c.toString(),children:c},c))})]})]}),e.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-secondary px-2 py-2",children:[e.jsx(R,{variant:"outline",size:"sm",onClick:()=>D(c=>Math.max(c-1,1)),disabled:n<=1,children:l("logs.table.pagination.previous")}),e.jsx("span",{className:"metric-number px-1 text-sm text-muted-foreground",children:l("logs.table.pagination.pageLabel",{page:C===0?0:n,total:C})}),e.jsx(R,{variant:"outline",size:"sm",onClick:()=>D(c=>C===0?c:Math.min(c+1,C)),disabled:C===0||n>=C,children:l("logs.table.pagination.next")})]})]})]})})}function tt({exportTimeoutMs:s,queryParams:l,total:p}){const{t:a}=I(),{pushToast:o}=fe(),[t,i]=x.useState(!1),b=x.useCallback(async()=>{if(!t){i(!0);try{const h=p>0?Math.min(p,5e3):1e3,d={...l,limit:h,offset:0},v=await be.exportArchive(d,s),y=new Date().toISOString().replace(/[:.]/g,"-"),w=URL.createObjectURL(v),m=document.createElement("a");m.href=w,m.download=`cc-gw-logs-${y}.zip`,document.body.appendChild(m),m.click(),m.remove(),URL.revokeObjectURL(w),o({title:a("logs.toast.exportSuccess.title"),description:a("logs.toast.exportSuccess.desc"),variant:"success"})}catch(h){const d=vs(h);o({title:a("logs.toast.exportError.title"),description:a("logs.toast.exportError.desc",{message:d.message}),variant:"error"})}finally{i(!1)}}},[s,t,o,l,a,p]);return{exporting:t,handleExport:b}}function lt(){const s=x.useRef(null),[l,p]=x.useState(!1),a=x.useCallback(()=>{const o=s.current;if(!o)return;const t=o.scrollWidth-o.scrollLeft-o.clientWidth>1;p(t)},[]);return x.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}}function at(){const[s,l]=A(P.logs.density,Ws,{serialize:v=>v,deserialize:v=>v==="compact"?"compact":"comfortable"}),[p,a]=A(P.logs.visibleColumns,J,{serialize:JSON.stringify,deserialize:v=>{try{const y=JSON.parse(v);if(!Array.isArray(y))return J;const w=y.filter(m=>oe.includes(m));return w.length>0?w:J}catch{return J}}}),{scrollRef:o,showScrollHint:t}=lt(),i=x.useMemo(()=>new Set(p),[p]),b=p.length+2,h=x.useCallback(v=>{a(y=>{if(y.includes(v))return y.length===1?y:y.filter(m=>m!==v);const w=[...y,v];return w.sort((m,N)=>oe.indexOf(m)-oe.indexOf(N)),w})},[]);return{resetVisibleColumns:x.useCallback(()=>{a(J)},[]),rowDensity:s,setRowDensity:l,showScrollHint:t,tableScrollRef:o,toggleColumn:h,visibleColumnCount:b,visibleColumns:p,visibleColumnSet:i}}const rt=3e3,ot=200;function nt(){var Ne,ke,Se,Ce,Le;const{t:s}=I(),{pushToast:l}=fe(),p=Qs(),[a,o]=A(P.logs.providerFilter,"all"),[t,i]=A(P.logs.endpointFilter,"all"),[b,h]=A(P.logs.modelFilter,""),[d,v]=A(P.logs.statusFilter,"all"),[y,w]=A(P.logs.fromDate,""),[m,N]=A(P.logs.toDate,""),[r,g]=x.useState(1),[L,f]=A(P.logs.autoRefresh,!0),[j,S]=A(P.logs.pageSize,Gs,{serialize:u=>String(u),deserialize:u=>{const k=Number(u);return X.includes(k)?k:X[0]}}),[n,C]=x.useState(null),[D,F]=x.useState(!1),[T,c]=x.useState(null),[_,ne]=A(P.logs.selectedApiKeys,[],{serialize:JSON.stringify,deserialize:u=>{try{const k=JSON.parse(u);return Array.isArray(k)?k.map(z=>Number(z)).filter(z=>Number.isInteger(z)&&z>0):[]}catch{return[]}}}),[Oe,Ie]=x.useState(!0),{resetVisibleColumns:$e,rowDensity:Qe,setRowDensity:Ue,showScrollHint:Ve,tableScrollRef:He,toggleColumn:Be,visibleColumnCount:We,visibleColumns:Ge,visibleColumnSet:Je}=at(),Xe=x.useDeferredValue(b),K=b===""?"":Xe;x.useEffect(()=>{g(1),c(null)},[a,t,K,d,y,m,j,_]);const ie=x.useMemo(()=>{const u={limit:j,offset:(r-1)*j};a!=="all"&&(u.provider=a),t!=="all"&&(u.endpoint=t),K.trim().length>0&&(u.model=K.trim()),d!=="all"&&(u.status=d);const k=Ee(y),z=Ee(m,!0);return k!==void 0&&(u.from=k),z!==void 0&&(u.to=z),_.length>0&&(u.apiKeys=_.join(",")),u},[K,t,y,r,j,a,_,d,m]),Q=G(H.logs.list(ie),be.listRequest(ie),{gcTime:6e4,refetchInterval:L&&r===1?rt:!1}),W=G(H.providers.all(),_e.providersRequest()),je=G(H.apiKeys.all(),{url:"/api/keys",method:"GET"}),de=G(H.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"}),ve=G(H.config.exportTimeout(),_e.configRequest());x.useEffect(()=>{!Q.isError||!Q.error||l({title:s("logs.toast.listError.title"),description:s("logs.toast.listError.desc",{message:Q.error.message}),variant:"error"})},[Q.error,Q.isError,l,s]),x.useEffect(()=>{!L||r!==1||typeof window>"u"||window.scrollY>=ot||window.scrollTo({top:0,behavior:"smooth"})},[L,r,Q.dataUpdatedAt]),x.useEffect(()=>{!W.isError||!W.error||l({title:s("logs.toast.providerError.title"),description:s("logs.toast.providerError.desc",{message:W.error.message}),variant:"error"})},[W.error,W.isError,l,s]);const se=((Ne=Q.data)==null?void 0:Ne.total)??0,Z=se>0?Math.ceil(se/j):0,Ye=((ke=Q.data)==null?void 0:ke.items)??[],Ze=x.useMemo(()=>{var k;const u=(k=ve.data)==null?void 0:k.logExportTimeoutSeconds;return typeof u=="number"&&Number.isFinite(u)?Math.min(Math.max(Math.round(u),5),600)*1e3:6e4},[(Se=ve.data)==null?void 0:Se.logExportTimeoutSeconds]);x.useEffect(()=>{Z>0&&r>Z&&g(Z)},[r,Z]);const ce=W.data??[],ue=x.useMemo(()=>{const u=new Map;for(const k of ce)k.id&&u.set(k.id,k.label??k.id);return u},[ce]),we=x.useMemo(()=>{var k;const u=new Map;u.set("anthropic",s("logs.filters.endpointAnthropic")),u.set("openai",s("logs.filters.endpointOpenAI"));for(const z of((k=de.data)==null?void 0:k.endpoints)??[])u.set(z.id,z.label||z.id);return u},[(Ce=de.data)==null?void 0:Ce.endpoints,s]),es=x.useMemo(()=>{const u=[];if(a!=="all"){const k=ue.get(a)??a;u.push({key:"provider",label:`${s("logs.filters.provider")}: ${k}`,onRemove:()=>o("all")})}if(t!=="all"){const k=we.get(t)??t;u.push({key:"endpoint",label:`${s("logs.filters.endpoint")}: ${k}`,onRemove:()=>i("all")})}if(K.trim()&&u.push({key:"model",label:`${s("logs.filters.modelId")}: ${K.trim()}`,onRemove:()=>h("")}),d!=="all"){const k=s(d==="success"?"logs.filters.statusSuccess":"logs.filters.statusError");u.push({key:"status",label:`${s("logs.filters.status")}: ${k}`,onRemove:()=>v("all")})}return y&&u.push({key:"from",label:`${s("logs.filters.startDate")}: ${y}`,onRemove:()=>w("")}),m&&u.push({key:"to",label:`${s("logs.filters.endDate")}: ${m}`,onRemove:()=>N("")}),_.length>0&&u.push({key:"apiKeys",label:s("logs.filters.apiKeySelected",{count:_.length}),onRemove:()=>ne([])}),u},[K,t,we,y,a,ue,_.length,d,s,m]),me=je.data??[],ss=x.useMemo(()=>{const u=new Map;for(const k of me)u.set(k.id,k);return u},[me]),ts=x.useMemo(()=>oe.map(u=>({id:u,label:s(`logs.table.columns.${u}`)})),[s]),ee=x.useMemo(()=>{const u=new Date;return`${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}`},[]),ls=x.useMemo(()=>a==="all"&&t==="all"&&K.trim()===""&&d==="all"&&y===""&&m===""&&_.length===0?"all":d==="error"&&t==="all"&&a==="all"&&K.trim()===""&&y===""&&m===""&&_.length===0?"errors":Js(y,m,ee)&&t==="all"&&a==="all"&&K.trim()===""&&d==="all"&&_.length===0?"today":t==="anthropic"&&a==="all"&&K.trim()===""&&d==="all"&&y===""&&m===""&&_.length===0?"anthropic":t==="openai"&&a==="all"&&K.trim()===""&&d==="all"&&y===""&&m===""&&_.length===0?"openai":null,[K,t,y,a,_.length,d,m,ee]),pe=x.useCallback(()=>{o("all"),h(""),i("all"),v("all"),w(""),N(""),ne([])},[]),as=x.useCallback(u=>{if(g(1),pe(),u!=="all"){if(u==="errors"){v("error");return}if(u==="today"){w(ee),N(ee);return}if(u==="anthropic"){i("anthropic");return}u==="openai"&&i("openai")}},[pe,ee]),{exporting:rs,handleExport:os}=tt({exportTimeoutMs:Ze,queryParams:ie,total:se}),ns=x.useCallback(u=>{p.removeQueries({queryKey:["logs","detail"],type:"inactive"}),C(u),F(!0)},[p]),is=x.useCallback(()=>{F(!1)},[]),ds=x.useCallback(u=>{c(k=>k===u?null:u)},[]);return x.useEffect(()=>{D||n===null||(p.removeQueries({queryKey:H.logs.detail(n),exact:!0}),C(null))},[D,p,n]),{activeFilters:es,activeQuickView:ls,apiKeyMap:ss,apiKeys:me,apiKeysQuery:je,applyQuickView:as,autoRefresh:L,columnOptions:ts,customEndpoints:(Le=de.data)==null?void 0:Le.endpoints,endpointFilter:t,exporting:rs,expandedLogId:T,filtersExpanded:Oe,fromDate:y,handleCloseDetail:is,handleExport:os,handleOpenDetail:ns,handleResetFilters:pe,handleToggleExpand:ds,isDetailOpen:D,items:Ye,logsQuery:Q,modelFilter:b,page:r,pageSize:j,providerFilter:a,providerLabelMap:ue,providerOptions:ce,rowDensity:Qe,resetVisibleColumns:$e,selectedApiKeys:_,selectedLogId:n,setAutoRefresh:f,setEndpointFilter:i,setFiltersExpanded:Ie,setFromDate:w,setModelFilter:h,setPage:g,setPageSize:S,setProviderFilter:o,setRowDensity:Ue,setSelectedApiKeys:ne,setStatusFilter:v,setToDate:N,showScrollHint:Ve,statusFilter:d,tableScrollRef:He,toDate:m,toggleColumn:Be,total:se,totalPages:Z,visibleColumnCount:We,visibleColumns:Ge,visibleColumnSet:Je}}function Et(){var l;const s=nt();return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(bs,{actions:e.jsx(Xs,{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(Vs,{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,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(st,{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,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(Hs,{open:s.isDetailOpen,logId:s.selectedLogId,onClose:s.handleCloseDetail,providerLabelMap:s.providerLabelMap,apiKeyMap:s.apiKeyMap})]})}export{Et as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as s}from"./vendor-D2wC0h2o.js";import{c as d}from"./card-DhuLMeO9.js";import{c as l}from"./global-CJOj9WGx.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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,N as c}from"./vendor-D2wC0h2o.js";import{c as i}from"./global-CJOj9WGx.js";const m={default:"border-border/30 bg-card",primary:"border-primary/10 bg-card",danger:"border-destructive/15 bg-card"},x={default:"bg-secondary text-primary",primary:"bg-primary/10 text-primary",danger:"bg-destructive/10 text-destructive"};function o({icon:r,title:a,description:t,action:s,className:n,compact:l=!1,tone:d="default"}){return e.jsxs("div",{className:i("flex flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 text-center",l?"min-h-[180px] py-8":"min-h-[260px] py-12",m[d],n),children:[r?e.jsx("div",{className:i("mb-4 flex h-12 w-12 items-center justify-center rounded-2xl",x[d]),children:r}):null,e.jsxs("div",{className:"max-w-xl space-y-1.5",children:[e.jsx("div",{className:"text-base font-semibold tracking-[-0.01em]",children:a}),t?e.jsx("div",{className:"text-sm text-muted-foreground",children:t}):null]}),s?e.jsx("div",{className:"mt-5 flex flex-wrap items-center justify-center gap-2",children:s}):null]})}function p({label:r,className:a,compact:t=!1}){return e.jsx(o,{className:a,compact:t,tone:"primary",icon:e.jsx(c,{className:"h-5 w-5 animate-spin","aria-hidden":"true"}),title:r})}export{p as P,o as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as r}from"./vendor-D2wC0h2o.js";import{c as m}from"./global-CJOj9WGx.js";function a({info:s,status:l,actions:e,className:t}){return!s&&!l&&!e?null:r.jsxs("div",{className:m("flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",t),children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[l,s]}),e?r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e}):null]})}export{a as P};
|