@chenpu17/cc-gw 0.8.0 → 0.8.2
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 +3 -3
- package/package.json +5 -5
- package/src/web/dist/assets/{About-DockN9He.js → About-BCHV3wbt.js} +1 -1
- package/src/web/dist/assets/ApiKeys-Do48QVpZ.js +1 -0
- package/src/web/dist/assets/Dashboard-BizLDn_V.js +1 -0
- package/src/web/dist/assets/{DialogShell-BKB8x8Yv.js → DialogShell-CiIvBp8J.js} +1 -1
- package/src/web/dist/assets/EChart-VRAvk6sX.js +1 -0
- package/src/web/dist/assets/{Events-CmUNBQ-L.js → Events-DpPg8dt0.js} +1 -1
- package/src/web/dist/assets/{Help-Bo6GcOG7.js → Help-B9ewdIkl.js} +1 -1
- package/src/web/dist/assets/{Login-uKKAO1uN.js → Login-5O2Xtr5G.js} +1 -1
- package/src/web/dist/assets/{Logs-ChD1V5Mf.js → Logs-D29vlNyO.js} +1 -1
- package/src/web/dist/assets/{ModelManagement-DTlt9WMp.js → ModelManagement-CrmNhCAh.js} +1 -1
- package/src/web/dist/assets/{PageHeader-DWkUnwoU.js → PageHeader-CSF0BWul.js} +1 -1
- package/src/web/dist/assets/{PageSection-9-z2ysug.js → PageSection-Bp_SuEp0.js} +1 -1
- package/src/web/dist/assets/{PageState-5sxEzXut.js → PageState-BeXrzVEe.js} +1 -1
- package/src/web/dist/assets/{Profiler-DBeKtgDs.js → Profiler-Cwuq3cjV.js} +1 -1
- package/src/web/dist/assets/{Settings-YMHmPlBz.js → Settings-Q6TBItFQ.js} +1 -1
- package/src/web/dist/assets/{Skeleton-CvBK2w-C.js → Skeleton-8j6Dxod1.js} +1 -1
- package/src/web/dist/assets/{badge-tREH_88e.js → badge-BvMdmUqJ.js} +1 -1
- package/src/web/dist/assets/{card-yK3LQB_K.js → card-CjhYPqKk.js} +1 -1
- package/src/web/dist/assets/{charts-core-vuhzGmuT.js → charts-core-C-3-Lo7l.js} +1 -1
- package/src/web/dist/assets/{charts-engine-BJQRnjQ_.js → charts-engine-BI1CmRJo.js} +1 -1
- package/src/web/dist/assets/{charts-react-BeVWPrMt.js → charts-react-DJ_0LNAP.js} +1 -1
- package/src/web/dist/assets/{gateway-D-NOc-e6.js → gateway-B0gBBN92.js} +1 -1
- package/src/web/dist/assets/{i18n-CfLThlXq.js → i18n-C7VVFIdN.js} +1 -1
- package/src/web/dist/assets/index-BzuBtvAC.js +61 -0
- package/src/web/dist/assets/{input-CXrASgDm.js → input-BnFZKjRM.js} +1 -1
- package/src/web/dist/assets/{label-CzHv4dNP.js → label-i5-Lf72z.js} +1 -1
- package/src/web/dist/assets/{popover-C-WmNbKp.js → popover-EFz6sQ7C.js} +1 -1
- package/src/web/dist/assets/{query-D3IfCUhp.js → query-DxhDvnDC.js} +1 -1
- package/src/web/dist/assets/{radix-54BMi3RD.js → radix-CmyU-WBH.js} +1 -1
- package/src/web/dist/assets/{router-CmaL1NgV.js → router-D8u_RlVh.js} +1 -1
- package/src/web/dist/assets/{select-DH6I1mKJ.js → select-KdDvaKo4.js} +1 -1
- package/src/web/dist/assets/{switch-IXq8M3lq.js → switch-BVWWsjy3.js} +1 -1
- package/src/web/dist/assets/{useApiQuery-CCy5_Mc8.js → useApiQuery-fBWRSgFK.js} +1 -1
- package/src/web/dist/assets/{useAppMutation-COEUmNH4.js → useAppMutation-Cd6HN12q.js} +1 -1
- package/src/web/dist/assets/{vendor-CjJPKsTb.js → vendor-5iCEqDpV.js} +1 -1
- package/src/web/dist/index.html +6 -6
- package/src/web/dist/assets/ApiKeys-Fx_SaOSe.js +0 -1
- package/src/web/dist/assets/Dashboard-De61szKh.js +0 -1
- package/src/web/dist/assets/EChart-Dqa_Xbrn.js +0 -1
- package/src/web/dist/assets/index-BiTh8byX.js +0 -61
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ GitHub 仓库:[chenpu17/cc-gw2](https://github.com/chenpu17/cc-gw2)
|
|
|
4
4
|
|
|
5
5
|
`cc-gw` 是一个本地网关项目,使用 Rust 重写原先的 Node.js 后端,同时保留现有 Web UI、CLI 使用方式、配置文件和 SQLite 数据格式的兼容性。
|
|
6
6
|
|
|
7
|
-
当前主线已收敛到 `v0.8.
|
|
7
|
+
当前主线已收敛到 `v0.8.2` 正式版,核心收益是后端完成 Rust 化之后,在相同常驻场景下内存占用实测可降至旧 Node.js 实现的约 `1/20`,同时继续保持对既有 CLI、Web UI、配置目录与 SQLite 数据的兼容。
|
|
8
8
|
|
|
9
9
|
说明:
|
|
10
10
|
|
|
@@ -142,8 +142,8 @@ Linux 版本使用 `musl`,Windows 版本使用静态 CRT,目标是让用户
|
|
|
142
142
|
```bash
|
|
143
143
|
pnpm pack:dry-run
|
|
144
144
|
pnpm --dir packages/native/darwin-arm64 pack --pack-destination ../../../.pack/native
|
|
145
|
-
npm install -g ./.pack/native/chenpu17-cc-gw-darwin-arm64-0.8.
|
|
146
|
-
npm install -g ./.pack/chenpu17-cc-gw-0.8.
|
|
145
|
+
npm install -g ./.pack/native/chenpu17-cc-gw-darwin-arm64-0.8.2.tgz
|
|
146
|
+
npm install -g ./.pack/chenpu17-cc-gw-0.8.2.tgz
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
当前发布目标:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenpu17/cc-gw",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Rust-backed local Claude Code compatible gateway with web console and CLI daemon.",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"optionalDependencies": {
|
|
28
|
-
"@chenpu17/cc-gw-
|
|
29
|
-
"@chenpu17/cc-gw-
|
|
30
|
-
"@chenpu17/cc-gw-
|
|
31
|
-
"@chenpu17/cc-gw-
|
|
28
|
+
"@chenpu17/cc-gw-linux-x64": "0.8.2",
|
|
29
|
+
"@chenpu17/cc-gw-darwin-arm64": "0.8.2",
|
|
30
|
+
"@chenpu17/cc-gw-win32-x64": "0.8.2",
|
|
31
|
+
"@chenpu17/cc-gw-linux-arm64": "0.8.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"colorette": "^2.0.20",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e,ab as P,aA as T,aB as u,aj as B,Z as R}from"./vendor-
|
|
1
|
+
import{r as c,j as e,ab as P,aA as T,aB as u,aj as B,Z as R}from"./vendor-5iCEqDpV.js";import{P as q}from"./PageHeader-CSF0BWul.js";import{P as m}from"./PageSection-Bp_SuEp0.js";import{P as A,a as C}from"./PageState-BeXrzVEe.js";import{u as I}from"./useApiQuery-fBWRSgFK.js";import{u as V,B as p}from"./index-BzuBtvAC.js";import{q as F}from"./queryKeys-BMvyDTQS.js";import{B as o}from"./badge-BvMdmUqJ.js";import{C as l,a as n}from"./card-CjhYPqKk.js";import{u as G}from"./i18n-C7VVFIdN.js";import"./query-DxhDvnDC.js";import"./router-D8u_RlVh.js";import"./radix-CmyU-WBH.js";const z="0.8.2",M={version:z};function ae(){var b,h,f,j,v,g,N,y,w,k;const{t:a}=G(),{pushToast:s}=V(),t=I(F.status.gateway(),{url:"/api/status",method:"GET"},{staleTime:6e4});c.useEffect(()=>{t.isError&&t.error&&s({title:a("about.toast.statusError.title"),description:t.error.message,variant:"error"})},[s,t.error,t.isError,a]);const i=M.version,d="2026-03-30T03:46:10.391Z",L=c.useMemo(()=>{var r,S;return[{label:a("about.app.labels.name"),value:e.jsx("span",{className:"font-mono",children:"cc-gw"})},{label:a("about.app.labels.version"),value:e.jsxs("span",{"data-visual-volatile":"true",className:"font-mono text-primary",children:["v",i]})},{label:a("about.app.labels.buildTime"),value:e.jsx("span",{"data-visual-volatile":"true",children:d}),hint:a("about.app.hint.buildTime")},{label:a("about.app.labels.runtime"),value:e.jsx("span",{className:"font-mono",children:((r=t.data)==null?void 0:r.runtime)??"rust"})},{label:a("about.app.labels.backendVersion"),value:e.jsx("span",{"data-visual-volatile":"true",className:"font-mono",children:((S=t.data)==null?void 0:S.backendVersion)??"-"})}]},[i,d,(b=t.data)==null?void 0:b.backendVersion,(h=t.data)==null?void 0:h.runtime,a]),x=c.useMemo(()=>{var r;return t.data?[{label:a("about.status.labels.host"),value:t.data.host??"127.0.0.1"},{label:a("about.status.labels.port"),value:e.jsx("span",{"data-visual-volatile":"true",children:t.data.port.toLocaleString()})},{label:a("about.status.labels.providers"),value:t.data.providers.toLocaleString()},{label:a("about.status.labels.active"),value:(t.data.activeRequests??0).toLocaleString(),hint:a("about.status.hint.active")},{label:a("about.status.labels.platform"),value:t.data.platform??"-"},{label:a("about.status.labels.pid"),value:e.jsx("span",{"data-visual-volatile":"true",children:((r=t.data.pid)==null?void 0:r.toLocaleString())??"-"})}]:[]},[t.data,a]);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(q,{icon:e.jsx(T,{className:"h-5 w-5","aria-hidden":"true"}),title:a("about.title"),description:a("about.description"),badge:e.jsxs("span",{"data-visual-volatile":"true",children:["v",i]}),eyebrow:"Runtime",breadcrumb:"Gateway / About",helper:a("about.support.description"),actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:"manual refresh only"}),e.jsxs(p,{onClick:()=>s({title:a("about.toast.updatesPlanned"),variant:"info"}),className:"w-full sm:w-auto",children:[e.jsx(P,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("about.support.actions.checkUpdates")]})]})}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.3fr)_minmax(320px,0.9fr)]",children:[e.jsx(l,{className:"overflow-hidden",children:e.jsx(n,{className:"pt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-primary/20 bg-accent px-3 py-1 text-xs font-semibold uppercase tracking-wider text-primary",children:[e.jsx(u,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Runtime snapshot"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"text-3xl font-semibold tracking-tight text-foreground",children:[((f=t.data)==null?void 0:f.host)??"127.0.0.1",":",((j=t.data)==null?void 0:j.port)??"-"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("about.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(o,{variant:"outline",children:((v=t.data)==null?void 0:v.runtime)??"rust"}),e.jsx(o,{variant:"outline",children:((g=t.data)==null?void 0:g.platform)??"-"}),e.jsxs(o,{variant:"secondary",children:[a("about.status.labels.providers"),": ",((y=(N=t.data)==null?void 0:N.providers)==null?void 0:y.toLocaleString())??"-"]}),e.jsxs(o,{variant:"secondary",children:[a("about.status.labels.active"),": ",(((w=t.data)==null?void 0:w.activeRequests)??0).toLocaleString()]})]})]})})}),e.jsx(l,{className:"overflow-hidden",children:e.jsx(n,{className:"pt-6",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Build"}),e.jsxs("p",{"data-visual-volatile":"true",className:"font-mono text-lg text-primary",children:["v",i]}),e.jsx("p",{"data-visual-volatile":"true",className:"text-sm text-muted-foreground",children:d}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-sm text-muted-foreground",children:a("about.support.tip")})]})})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(m,{title:a("about.app.title"),description:a("about.app.subtitle"),children:e.jsx(E,{items:L})}),e.jsx(m,{title:a("about.status.title"),description:a("about.status.subtitle"),actions:e.jsxs(p,{variant:"outline",size:"sm",onClick:()=>void t.refetch(),disabled:t.isFetching,children:[e.jsx(B,{className:Q(t.isFetching),"aria-hidden":"true"}),t.isFetching?a("common.actions.refreshing"):a("common.actions.refresh")]}),children:t.isLoading?e.jsx(A,{compact:!0,label:a("about.status.loading")}):t.isError?e.jsx(C,{compact:!0,tone:"danger",icon:e.jsx(u,{className:"h-5 w-5","aria-hidden":"true"}),title:a("common.status.error"),description:((k=t.error)==null?void 0:k.message)??a("common.unknownError"),action:e.jsx(p,{variant:"outline",size:"sm",onClick:()=>void t.refetch(),children:a("common.actions.refresh")})}):x.length>0?e.jsx(E,{items:x}):e.jsx(C,{compact:!0,tone:"primary",icon:e.jsx(u,{className:"h-5 w-5","aria-hidden":"true"}),title:a("about.status.empty"),description:a("common.actions.refresh")})})]}),e.jsx(m,{title:a("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-medium text-primary",children:a("about.support.subtitle")}),e.jsx("span",{children:a("about.support.description")})]}),children:e.jsx(l,{children:e.jsxs(n,{className:"flex flex-col gap-4 pt-5 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:e.jsx(R,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:a("about.support.tip")})]}),e.jsx("code",{className:"inline-flex self-start rounded-lg border border-border bg-secondary px-3 py-2 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}function E({items:a}){return a.length===0?null:e.jsx("dl",{className:"grid gap-4 sm:grid-cols-2",children:a.map(s=>e.jsx(l,{children:e.jsxs(n,{className:"pt-5",children:[e.jsx("dt",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:s.label}),e.jsx("dd",{className:"mt-2 text-sm font-semibold text-foreground",children:s.value}),s.hint?e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.hint}):null]})},s.label))})}function Q(a){return`mr-2 h-4 w-4${a?" animate-spin":""}`}export{ae as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as c,j as e,a2 as Ze,au as ve,W as Ke,av as Ne,aw as we,ax as es,ay as ss,as}from"./vendor-5iCEqDpV.js";import{c as se,r as ts,h as B,b as U,B as K,u as ns,a as _,s as J,L as rs}from"./index-BzuBtvAC.js";import{P as is}from"./PageHeader-CSF0BWul.js";import{C as ls,u as z}from"./useAppMutation-Cd6HN12q.js";import{D as ae,A as te,a as ne,b as re,c as Ce,d as ie,e as le}from"./DialogShell-CiIvBp8J.js";import{I as $}from"./input-BnFZKjRM.js";import{L as O}from"./label-i5-Lf72z.js";import{u as H}from"./useApiQuery-fBWRSgFK.js";import{q as v}from"./queryKeys-BMvyDTQS.js";import{u as N}from"./i18n-C7VVFIdN.js";import{E as os}from"./EChart-VRAvk6sX.js";import{P as oe}from"./PageSection-Bp_SuEp0.js";import{B as C}from"./badge-BvMdmUqJ.js";import{C as de,a as ce}from"./card-CjhYPqKk.js";import{e as ds}from"./charts-core-C-3-Lo7l.js";import{c as cs}from"./clipboard-CALi6bTW.js";import"./query-DxhDvnDC.js";import"./router-D8u_RlVh.js";import"./radix-CmyU-WBH.js";import"./charts-react-DJ_0LNAP.js";import"./charts-engine-BI1CmRJo.js";const Ee=c.forwardRef(({className:s,...a},i)=>e.jsx("textarea",{className:se("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:i,...a}));Ee.displayName="Textarea";const A={listRequest(){return{url:"/api/keys",method:"GET"}},overviewRequest(s){return{url:"/api/stats/api-keys/overview",method:"GET",params:{days:s}}},usageRequest(s,a=10){return{url:"/api/stats/api-keys/usage",method:"GET",params:{days:s,limit:a}}},customEndpointOptionsRequest(){return{url:"/api/custom-endpoints",method:"GET"}},create:async s=>B(U.post("/api/keys",s)),update:async(s,a)=>{await B(U.patch(`/api/keys/${s}`,a))},delete:async s=>{await B(U.delete(`/api/keys/${s}`))},reveal:async s=>ts({url:`/api/keys/${s}/reveal`,method:"GET"})},ke=[{value:1,labelKey:"apiKeys.analytics.range.today"},{value:7,labelKey:"apiKeys.analytics.range.week"},{value:30,labelKey:"apiKeys.analytics.range.month"}];function ps(){var i;const s=[{id:"anthropic",label:"Anthropic"},{id:"openai",label:"OpenAI"}],a=H(v.customEndpoints.all(),A.customEndpointOptionsRequest());return c.useMemo(()=>{var l;const t=(((l=a.data)==null?void 0:l.endpoints)??[]).map(u=>({id:u.id,label:u.label||u.id}));return[...s,...t]},[(i=a.data)==null?void 0:i.endpoints])}function De({available:s,hint:a,onChange:i,selected:t}){const{t:l}=N(),u=t.length===0,g=()=>{i([])},j=o=>{if(t.includes(o)){i(t.filter(p=>p!==o));return}i([...t,o])};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-3 text-xs text-muted-foreground",children:a}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-lg border border-border bg-card px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-accent/50",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:g,className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm font-medium",children:l("apiKeys.allEndpoints")})]}),e.jsx("div",{className:"grid max-h-40 gap-1 overflow-y-auto",children:s.map(o=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-lg border border-border bg-card px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-accent/50",children:[e.jsx("input",{type:"checkbox",checked:!u&&t.includes(o.id),onChange:()=>j(o.id),className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm",children:o.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",o.id,")"]})]},o.id))})]})}function us({availableEndpoints:s,isOpen:a,keyDescription:i,keyName:t,maxConcurrency:l,onDescriptionChange:u,onEndpointsChange:g,onKeyNameChange:j,onMaxConcurrencyChange:o,onOpenChange:p,onSubmit:y,selectedEndpoints:r}){const{t:x}=N();return e.jsx(ae,{open:a,onOpenChange:p,children:e.jsxs(te,{className:"max-w-2xl",children:[e.jsxs(ne,{children:[e.jsx(re,{children:x("apiKeys.createNew")}),e.jsx(Ce,{children:x("apiKeys.createDescription")})]}),e.jsxs(ie,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border border-primary/20 bg-accent px-4 py-3 text-xs text-primary",children:x("apiKeys.selectEndpoints")}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[1rem] border border-blue-200 bg-blue-50/70 px-3 py-3 text-xs text-blue-900 dark:border-blue-800 dark:bg-blue-950/30 dark:text-blue-100",children:[e.jsx("p",{className:"font-semibold",children:"Restricted"}),e.jsx("p",{className:"mt-1 text-blue-800/85 dark:text-blue-100/80",children:"Select explicit endpoints before saving."})]}),e.jsxs("div",{className:"rounded-[1rem] border border-amber-200 bg-amber-50/70 px-3 py-3 text-xs text-amber-900 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-100",children:[e.jsx("p",{className:"font-semibold",children:"Unrestricted"}),e.jsx("p",{className:"mt-1 text-amber-800/85 dark:text-amber-100/80",children:"Leave endpoint selection empty for broad access."})]}),e.jsxs("div",{className:"rounded-[1rem] border border-rose-200 bg-rose-50/70 px-3 py-3 text-xs text-rose-900 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-100",children:[e.jsx("p",{className:"font-semibold",children:"Wildcard"}),e.jsx("p",{className:"mt-1 text-rose-800/85 dark:text-rose-100/80",children:"Special-case key with the highest blast radius."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(O,{htmlFor:"keyName",children:[x("apiKeys.keyNamePlaceholder")," *"]}),e.jsx($,{id:"keyName",value:t,onChange:h=>j(h.target.value),placeholder:x("apiKeys.keyNamePlaceholder"),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),y())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"keyDescription",children:x("apiKeys.descriptionLabel")}),e.jsx(Ee,{id:"keyDescription",value:i,onChange:h=>u(h.target.value),placeholder:x("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:x("apiKeys.allowedEndpoints")}),e.jsx(De,{available:s,selected:r,onChange:g,hint:x("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"maxConcurrency",children:x("apiKeys.maxConcurrency")}),e.jsx($,{id:"maxConcurrency",type:"number",min:"0",value:l,onChange:h=>o(h.target.value),placeholder:x("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(le,{children:[e.jsx(K,{variant:"outline",onClick:()=>p(!1),children:x("common.actions.cancel")}),e.jsx(K,{onClick:y,children:x("apiKeys.createAction")})]})]})})}function xs({createdKey:s,onClose:a,onCopy:i}){const{t}=N();return e.jsx(ae,{open:!!s,onOpenChange:l=>{l||a()},children:e.jsxs(te,{className:"max-w-xl",children:[e.jsx(ne,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-600",children:e.jsx(Ze,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(re,{children:t("apiKeys.keyCreated")})]})}),e.jsxs(ie,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:t("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 font-mono text-sm",children:s==null?void 0:s.key}),s!=null&&s.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:s.description}):null]}),e.jsxs(le,{children:[e.jsxs(K,{onClick:()=>i((s==null?void 0:s.key)??""),children:[e.jsx(ve,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),t("common.actions.copy")]}),e.jsx(K,{variant:"outline",onClick:a,children:t("common.actions.close")})]})]})})}function ms({apiKey:s,availableEndpoints:a,maxConcurrency:i,onClose:t,onEndpointsChange:l,onMaxConcurrencyChange:u,onSave:g,selectedEndpoints:j}){const{t:o}=N();return e.jsx(ae,{open:!!s,onOpenChange:p=>{p||t()},children:e.jsxs(te,{className:"max-w-2xl",children:[e.jsxs(ne,{children:[e.jsx(re,{children:o("apiKeys.editEndpoints")}),e.jsx(Ce,{children:s==null?void 0:s.name})]}),e.jsxs(ie,{className:"space-y-4",children:[!(s!=null&&s.isWildcard)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border border-[hsl(var(--warning)/0.3)] bg-[hsl(var(--warning-bg))] px-4 py-3 text-xs text-[hsl(var(--warning)/1)]",children:o("apiKeys.allEndpoints")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-xs text-muted-foreground",children:"Empty selection means unrestricted access. Only explicit selections create a restricted key scope."}),e.jsx(De,{available:a,selected:j,onChange:l,hint:o("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"editMaxConcurrency",children:o("apiKeys.maxConcurrency")}),e.jsx($,{id:"editMaxConcurrency",type:"number",min:"0",value:i,onChange:p=>u(p.target.value),placeholder:o("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(le,{children:[e.jsx(K,{variant:"outline",onClick:t,children:o("common.actions.cancel")}),e.jsx(K,{onClick:g,children:o("common.save")})]})]})})}function ys({deleteTarget:s,isDeleting:a,onConfirm:i,onOpenChange:t}){const{t:l}=N();return e.jsx(ls,{open:!!s,onOpenChange:t,title:l("apiKeys.deleteDialogTitle"),description:l("apiKeys.confirmDelete"),confirmLabel:s&&a===s.id?l("common.actions.loading"):l("apiKeys.actions.delete"),cancelLabel:l("common.actions.cancel"),loading:s?a===s.id:!1,onConfirm:i,children:s?e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 font-mono text-xs text-foreground",children:s.name}):null})}function hs(){const{t:s}=N();return e.jsx(oe,{eyebrow:"Recommended",title:s("apiKeys.quickStart.title"),description:s("apiKeys.quickStart.description"),contentClassName:"pt-5",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(X,{icon:e.jsx(Ke,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.create.title"),description:s("apiKeys.quickStart.create.description")}),e.jsx(X,{icon:e.jsx(Ne,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.restrict.title"),description:s("apiKeys.quickStart.restrict.description")}),e.jsx(X,{icon:e.jsx(we,{className:"h-4 w-4","aria-hidden":"true"}),title:s("apiKeys.quickStart.wildcard.title"),description:s("apiKeys.quickStart.wildcard.description")})]})})}function gs({activeKeysValue:s,enabledKeysValue:a,loading:i,onRangeChange:t,rangeDays:l,requestsChartOption:u,totalKeysValue:g,tokensChartOption:j,usageLength:o}){const{t:p}=N();return e.jsx(oe,{eyebrow:"Usage",title:p("apiKeys.analytics.title"),description:p("apiKeys.analytics.description",{days:l}),actions:e.jsx("div",{className:"flex w-full items-center gap-1 overflow-x-auto rounded-full border border-border bg-secondary p-1 sm:w-auto",children:ke.map(y=>{const r=l===y.value;return e.jsx("button",{type:"button",onClick:()=>t(y.value),className:se("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",r?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:p(y.labelKey)},y.value)})}),children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(Y,{label:p("apiKeys.analytics.cards.total"),value:g}),e.jsx(Y,{label:p("apiKeys.analytics.cards.enabled"),value:a}),e.jsx(Y,{label:p("apiKeys.analytics.cards.active",{days:l}),value:s})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(fe,{title:p("apiKeys.analytics.charts.requests"),loading:i,empty:o===0,emptyText:p("apiKeys.analytics.empty"),option:u}),e.jsx(fe,{title:p("apiKeys.analytics.charts.tokens"),loading:i,empty:o===0,emptyText:p("apiKeys.analytics.empty"),option:j})]})]})})}function bs({filteredKeys:s,formatDate:a,hasWildcard:i,isDeleting:t,isRevealing:l,keys:u,onCopy:g,onDelete:j,onEditEndpoints:o,onFilterChange:p,onHide:y,onReveal:r,onStatusFilterChange:x,onToggleEnabled:h,restrictedCount:E,revealedKeys:T,search:w,statusFilter:q,unrestrictedCount:f,wildcardCount:M}){const{t:m}=N();return e.jsx(oe,{eyebrow:"Inventory",title:m("apiKeys.list.title"),description:i?m("apiKeys.wildcardHint"):void 0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{variant:"outline",children:`${s.length}/${u.length}`}),e.jsx(C,{variant:"outline",children:m("apiKeys.summary.wildcard",{count:M})}),e.jsx(C,{variant:"outline",children:m("apiKeys.summary.restricted",{count:E})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(Z,{label:m("apiKeys.list.title"),value:`${s.length}/${u.length}`,helper:m("apiKeys.filters.searchPlaceholder")}),e.jsx(Z,{label:m("apiKeys.summary.wildcard",{count:M}),value:String(M),helper:m("apiKeys.wildcardHint")}),e.jsx(Z,{label:m("apiKeys.summary.restricted",{count:E}),value:String(E),helper:m("apiKeys.summary.unrestricted",{count:f})})]}),e.jsxs("div",{className:"grid gap-3 rounded-lg border border-border bg-secondary p-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,360px)] xl:grid-cols-[minmax(0,1fr)_180px_auto]",children:[e.jsx($,{value:w,onChange:b=>p(b.target.value),placeholder:m("apiKeys.filters.searchPlaceholder")}),e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto rounded-full border border-border bg-secondary p-1",children:["all","enabled","disabled"].map(b=>e.jsx("button",{type:"button",onClick:()=>x(b),className:se("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",q===b?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:m(`apiKeys.filters.${b}`)},b))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:col-span-2 xl:col-span-1",children:[e.jsx(C,{variant:"secondary",children:m("apiKeys.summary.wildcard",{count:M})}),e.jsx(C,{variant:"secondary",children:m("apiKeys.summary.restricted",{count:E})})]})]}),u.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed border-border",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:m("apiKeys.list.empty")})}):s.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-lg border border-dashed border-border",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:m("apiKeys.list.emptyFiltered")})}):e.jsx("div",{className:"grid gap-4",children:s.map(b=>e.jsx(js,{formatDate:a,isDeleting:t===b.id,isRevealing:l===b.id,keySummary:b,onCopy:g,onDelete:j,onEditEndpoints:o,onHide:y,onReveal:r,onToggleEnabled:h,revealedValue:T.get(b.id)},b.id))})]})})}function X({description:s,icon:a,title:i}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:a}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-foreground",children:i}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s})]})}function js({formatDate:s,isDeleting:a,isRevealing:i,keySummary:t,onCopy:l,onDelete:u,onEditEndpoints:g,onHide:j,onReveal:o,onToggleEnabled:p,revealedValue:y}){var h,E,T,w;const{t:r}=N(),x=(t.totalInputTokens+t.totalOutputTokens).toLocaleString();return t.isWildcard||(((h=t.allowedEndpoints)==null?void 0:h.length)??0)>0,e.jsx(de,{"data-testid":"api-key-card",children:e.jsx(ce,{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold",children:t.name}),t.isWildcard?e.jsx(C,{variant:"secondary",children:r("apiKeys.wildcard")}):null,e.jsx(C,{variant:t.enabled?"default":"outline",children:t.enabled?r("apiKeys.status.enabled"):r("apiKeys.status.disabled")}),t.isWildcard?null:e.jsx(C,{variant:"outline",className:"text-xs",children:(((E=t.allowedEndpoints)==null?void 0:E.length)??0)>0?r("apiKeys.endpointRestricted"):r("apiKeys.allEndpoints")}),!t.isWildcard&&t.allowedEndpoints&&t.allowedEndpoints.length>0?t.allowedEndpoints.map(q=>e.jsx(C,{variant:"outline",className:"text-xs",children:q},q)):t.isWildcard?null:e.jsx(C,{variant:"secondary",className:"text-xs opacity-60",children:r("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx(ee,{label:r("apiKeys.requestCount"),value:t.requestCount.toLocaleString()}),e.jsx(ee,{label:r("apiKeys.totalTokens"),value:x}),e.jsx(ee,{label:r("apiKeys.maxConcurrency"),value:t.maxConcurrency?String(t.maxConcurrency):r("apiKeys.maxConcurrencyPlaceholder")})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("code",{className:"block max-w-full break-all rounded-lg border border-border bg-secondary px-3 py-1.5 font-mono text-sm",children:t.isWildcard?r("apiKeys.wildcard"):y??t.maskedKey??"********"}),t.isWildcard?null:e.jsx("div",{className:"flex items-center gap-1 self-start",children:y?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(y),"aria-label":r("common.actions.copy"),title:r("common.actions.copy"),children:e.jsx(ve,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(t.id),"aria-label":r("apiKeys.actions.hide"),title:r("apiKeys.actions.hide"),children:e.jsx(we,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(t.id),disabled:i,"aria-label":r("apiKeys.actions.reveal"),title:r("apiKeys.actions.reveal"),children:i?e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(es,{className:"h-4 w-4","aria-hidden":"true"})})})]}),t.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:r("apiKeys.wildcardHint")}):t.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:t.description}):null,t.isWildcard?null:e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:(((T=t.allowedEndpoints)==null?void 0:T.length)??0)>0?`${r("apiKeys.allowedEndpoints")}: ${(w=t.allowedEndpoints)==null?void 0:w.join(", ")}`:r("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:r("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:s(t.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:r("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:s(t.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:flex lg:flex-wrap lg:justify-end",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>g(t),className:"w-full lg:w-auto",children:[e.jsx(Ne,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),t.isWildcard?r("apiKeys.maxConcurrency"):r("apiKeys.editEndpoints")]}),e.jsx(K,{variant:t.enabled?"outline":"default",size:"sm",onClick:()=>p(t.id,t.enabled),className:"w-full lg:w-auto",children:t.enabled?r("apiKeys.actions.disable"):r("apiKeys.actions.enable")}),t.isWildcard?null:e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-full text-destructive hover:bg-destructive/10 hover:text-destructive sm:w-9",onClick:()=>u(t),disabled:a,"aria-label":r("apiKeys.actions.delete"),children:e.jsx(ss,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})})}function Y({label:s,value:a}){return e.jsx(de,{children:e.jsxs(ce,{className:"pt-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:s}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-foreground",children:a})]})})}function Z({helper:s,label:a,value:i}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"mt-2 text-lg font-semibold text-foreground",children:i}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]})}function ee({label:s,value:a}){return e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:a})]})}function fe({empty:s,emptyText:a,loading:i,option:t,title:l}){const{t:u}=N();return e.jsx(de,{children:e.jsxs(ce,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:l}),i?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:u("common.loadingShort")})}):s?e.jsx("div",{className:"flex h-[280px] items-center justify-center rounded-lg border border-dashed border-border",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:a})}):e.jsx(os,{echarts:ds,option:t,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}function fs(){const{t:s}=N(),{pushToast:a}=ns(),[i,t]=c.useState(!1),[l,u]=c.useState(""),[g,j]=c.useState(""),[o,p]=c.useState([]),[y,r]=c.useState(""),[x,h]=c.useState(null),[E,T]=c.useState(null),[w,q]=c.useState(null),[f,M]=_(J.apiKeys.rangeDays,7,{serialize:n=>String(n),deserialize:n=>{const d=Number(n);return ke.some(k=>k.value===d)?d:7}}),[m,b]=c.useState(new Map),[Ae,pe]=c.useState(null),[F,Q]=c.useState(null),[W,ue]=c.useState([]),[L,xe]=c.useState(""),[V,Te]=_(J.apiKeys.search,""),[P,qe]=_(J.apiKeys.statusFilter,"all",{serialize:n=>n,deserialize:n=>n==="enabled"||n==="disabled"?n:"all"}),Se=ps(),me=H(v.apiKeys.all(),A.listRequest()),Me=H(v.apiKeys.overview(f),A.overviewRequest(f)),ye=H(v.apiKeys.usage(f),A.usageRequest(f)),he=z({mutationFn:A.create,invalidateKeys:[v.apiKeys.all(),v.apiKeys.overview(f),v.apiKeys.usage(f)],successToast:()=>({title:s("apiKeys.toast.keyCreated")}),errorToast:n=>({title:s("apiKeys.toast.createFailure",{message:n.message})})}),I=z({mutationFn:({id:n,...d})=>A.update(n,d),invalidateKeys:[v.apiKeys.all(),v.apiKeys.overview(f),v.apiKeys.usage(f)],successToast:()=>({title:s("apiKeys.toast.keyUpdated")}),errorToast:n=>({title:s("apiKeys.toast.updateFailure",{message:n.message})})}),ge=z({mutationFn:({id:n})=>A.delete(n),invalidateKeys:[v.apiKeys.all(),v.apiKeys.overview(f),v.apiKeys.usage(f)],successToast:()=>({title:s("apiKeys.toast.keyDeleted")}),errorToast:n=>({title:s("apiKeys.toast.deleteFailure",{message:n.message})})}),be=z({mutationFn:({id:n})=>A.reveal(n),errorToast:n=>({title:s("apiKeys.toast.revealFailure"),description:n.message})}),S=me.data??[],R=Me.data,D=ye.data??[],Re=S.some(n=>n.isWildcard),Fe=S.filter(n=>n.isWildcard).length,Oe=S.filter(n=>{var d;return!n.isWildcard&&(((d=n.allowedEndpoints)==null?void 0:d.length)??0)>0}).length,We=S.filter(n=>{var d;return!n.isWildcard&&(((d=n.allowedEndpoints)==null?void 0:d.length)??0)===0}).length,Le=R?R.totalKeys.toLocaleString():"-",Pe=R?R.enabledKeys.toLocaleString():"-",Ie=R?R.activeKeys.toLocaleString():"-",ze=c.useMemo(()=>S.filter(n=>{if(!(P==="all"||(P==="enabled"?n.enabled:!n.enabled)))return!1;const k=V.trim().toLowerCase();return k?[n.name,n.description??"",n.maskedKey??"",...n.allowedEndpoints??[]].join(" ").toLowerCase().includes(k):!0}),[S,V,P]),He=c.useMemo(()=>{const n=D.map(d=>d.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:n,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.requestsSeries"),type:"bar",data:D.map(d=>d.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[s,D]),$e=c.useMemo(()=>{const n=D.map(d=>d.apiKeyName??s("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[s("apiKeys.analytics.tokens.input"),s("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:n,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:s("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:D.map(d=>d.inputTokens)},{name:s("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:D.map(d=>d.outputTokens)}]}},[s,D]),je=c.useCallback(()=>{u(""),j(""),p([]),r("")},[]),G=c.useCallback(n=>{t(n),n||je()},[je]),Qe=c.useCallback(async()=>{if(!l.trim()){a({title:s("apiKeys.errors.nameRequired"),variant:"error"});return}try{const n=await he.mutateAsync({name:l.trim(),description:g.trim()||void 0,allowedEndpoints:o.length>0?o:void 0,maxConcurrency:y?Number(y):null});h(n),G(!1)}catch{}},[he,G,g,o,y,l,a,s]),Ve=c.useCallback(async(n,d)=>{try{await I.mutateAsync({id:n,enabled:!d})}catch{}},[I]),Ge=c.useCallback(async()=>{if(w){T(w.id);try{await ge.mutateAsync({id:w.id}),q(null)}catch{}finally{T(null)}}},[w,ge]),Be=c.useCallback(async n=>{if(!m.has(n)){pe(n);try{const d=await be.mutateAsync({id:n});b(k=>new Map(k).set(n,d.key))}catch{}finally{pe(null)}}},[be,m]),Ue=c.useCallback(n=>{b(d=>{const k=new Map(d);return k.delete(n),k})},[]),_e=c.useCallback(async n=>{try{await cs(n),a({title:s("apiKeys.toast.keyCopied"),variant:"success"})}catch(d){a({title:s("apiKeys.toast.copyFailure"),description:d instanceof Error?d.message:s("common.unknownError"),variant:"error"})}},[a,s]),Je=c.useCallback(n=>{Q(n),ue(n.allowedEndpoints??[]),xe(n.maxConcurrency?String(n.maxConcurrency):"")},[]),Xe=c.useCallback(async()=>{if(F)try{await I.mutateAsync({id:F.id,...F.isWildcard?{}:{allowedEndpoints:W.length>0?W:null},maxConcurrency:L?Number(L):null}),Q(null)}catch{}},[F,W,L,I]),Ye=c.useCallback(n=>n?new Date(n).toLocaleString():s("common.noData"),[s]);return{activeKeysValue:Ie,availableEndpoints:Se,deleteTarget:w,editEndpointsKey:F,editEndpointsSelection:W,editMaxConcurrency:L,enabledKeysValue:Pe,filteredKeys:ze,formatDate:Ye,handleCopyKey:_e,handleCreateDialogChange:G,handleCreateKey:Qe,handleDeleteKey:Ge,handleHideKey:Ue,handleOpenEditEndpoints:Je,handleRevealKey:Be,handleSaveEndpoints:Xe,handleToggleEnabled:Ve,hasWildcard:Re,isCreateDialogOpen:i,isDeleting:E,isRevealing:Ae,keys:S,keysQuery:me,newKeyDescription:g,newKeyEndpoints:o,newKeyMaxConcurrency:y,newKeyName:l,newlyCreatedKey:x,rangeDays:f,requestsChartOption:He,restrictedCount:Oe,revealedKeys:m,search:V,setDeleteTarget:q,setEditEndpointsKey:Q,setEditEndpointsSelection:ue,setEditMaxConcurrency:xe,setNewKeyDescription:j,setNewKeyEndpoints:p,setNewKeyMaxConcurrency:r,setNewKeyName:u,setNewlyCreatedKey:h,setRangeDays:M,setSearch:Te,setStatusFilter:qe,statusFilter:P,tokensChartOption:$e,totalKeysValue:Le,unrestrictedCount:We,usage:D,usageQuery:ye,wildcardCount:Fe}}function Hs(){const{t:s}=N(),a=fs(),i=s("apiKeys.summary.totalCount",{count:a.keys.length});return a.keysQuery.isLoading?e.jsx(rs,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(is,{icon:e.jsx(Ke,{className:"h-5 w-5","aria-hidden":"true"}),title:s("apiKeys.title"),description:s("apiKeys.description"),eyebrow:"Access Control",breadcrumb:"Gateway / API Keys",helper:s("apiKeys.helper"),badge:i,actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:[s("apiKeys.summary.wildcard",{count:a.wildcardCount})," / ",s("apiKeys.summary.restricted",{count:a.restrictedCount})," / ",s("apiKeys.summary.unrestricted",{count:a.unrestrictedCount})]}),e.jsxs(K,{onClick:()=>a.handleCreateDialogChange(!0),className:"w-full sm:w-auto",children:[e.jsx(as,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),s("apiKeys.createNew")]})]})}),e.jsx(hs,{}),e.jsx(gs,{activeKeysValue:a.activeKeysValue,enabledKeysValue:a.enabledKeysValue,loading:a.usageQuery.isLoading,onRangeChange:a.setRangeDays,rangeDays:a.rangeDays,requestsChartOption:a.requestsChartOption,totalKeysValue:a.totalKeysValue,tokensChartOption:a.tokensChartOption,usageLength:a.usage.length}),e.jsx(bs,{filteredKeys:a.filteredKeys,formatDate:a.formatDate,hasWildcard:a.hasWildcard,isDeleting:a.isDeleting,isRevealing:a.isRevealing,keys:a.keys,onCopy:t=>void a.handleCopyKey(t),onDelete:a.setDeleteTarget,onEditEndpoints:a.handleOpenEditEndpoints,onFilterChange:a.setSearch,onHide:a.handleHideKey,onReveal:t=>void a.handleRevealKey(t),onStatusFilterChange:a.setStatusFilter,onToggleEnabled:(t,l)=>void a.handleToggleEnabled(t,l),restrictedCount:a.restrictedCount,revealedKeys:a.revealedKeys,search:a.search,statusFilter:a.statusFilter,unrestrictedCount:a.unrestrictedCount,wildcardCount:a.wildcardCount}),e.jsx(us,{availableEndpoints:a.availableEndpoints,isOpen:a.isCreateDialogOpen,keyDescription:a.newKeyDescription,keyName:a.newKeyName,maxConcurrency:a.newKeyMaxConcurrency,onDescriptionChange:a.setNewKeyDescription,onEndpointsChange:a.setNewKeyEndpoints,onKeyNameChange:a.setNewKeyName,onMaxConcurrencyChange:a.setNewKeyMaxConcurrency,onOpenChange:a.handleCreateDialogChange,onSubmit:()=>void a.handleCreateKey(),selectedEndpoints:a.newKeyEndpoints}),e.jsx(xs,{createdKey:a.newlyCreatedKey,onClose:()=>a.setNewlyCreatedKey(null),onCopy:t=>void a.handleCopyKey(t)}),e.jsx(ms,{apiKey:a.editEndpointsKey,availableEndpoints:a.availableEndpoints,maxConcurrency:a.editMaxConcurrency,onClose:()=>a.setEditEndpointsKey(null),onEndpointsChange:a.setEditEndpointsSelection,onMaxConcurrencyChange:a.setEditMaxConcurrency,onSave:()=>void a.handleSaveEndpoints(),selectedEndpoints:a.editEndpointsSelection}),e.jsx(ys,{deleteTarget:a.deleteTarget,isDeleting:a.isDeleting,onConfirm:()=>void a.handleDeleteKey(),onOpenChange:t=>{!t&&a.isDeleting===null&&a.setDeleteTarget(null)}})]})}export{Hs as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,j as e,ab as ie,ac as qe,X as K,ad as ce,ae as Pe,af as me,ag as Me,ah as Ae,S as Q,ai as De,aj as Be,V as Fe}from"./vendor-5iCEqDpV.js";import{P as Oe}from"./PageHeader-CSF0BWul.js";import{P as Y,a as z}from"./PageState-BeXrzVEe.js";import{c as S,u as _e,a as $e,b as Ge,t as He,s as Qe,B as V}from"./index-BzuBtvAC.js";import{S as ze,a as Ve,b as Ue,c as Ke,d as _}from"./select-KdDvaKo4.js";import{E as Ye}from"./EChart-VRAvk6sX.js";import{P as he}from"./PageSection-Bp_SuEp0.js";import{S as Xe,C as Ze,T as Je}from"./Skeleton-8j6Dxod1.js";import{B as E}from"./badge-BvMdmUqJ.js";import{C as B,a as F}from"./card-CjhYPqKk.js";import{u as C}from"./i18n-C7VVFIdN.js";import{e as We}from"./charts-core-C-3-Lo7l.js";import{u as w}from"./useApiQuery-fBWRSgFK.js";import{q as L}from"./queryKeys-BMvyDTQS.js";import"./query-DxhDvnDC.js";import"./router-D8u_RlVh.js";import"./radix-CmyU-WBH.js";import"./charts-react-DJ_0LNAP.js";import"./charts-engine-BI1CmRJo.js";const X=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:"relative w-full overflow-auto rounded-lg border border-border bg-background",children:e.jsx("table",{ref:a,className:S("w-full caption-bottom border-collapse text-sm",t),...s})}));X.displayName="Table";const Z=i.forwardRef(({className:t,...s},a)=>e.jsx("thead",{ref:a,className:S("bg-muted/35 [&_tr]:border-b [&_tr]:border-border/60",t),...s}));Z.displayName="TableHeader";const J=i.forwardRef(({className:t,...s},a)=>e.jsx("tbody",{ref:a,className:S("[&_tr:last-child]:border-0",t),...s}));J.displayName="TableBody";const et=i.forwardRef(({className:t,...s},a)=>e.jsx("tfoot",{ref:a,className:S("border-t bg-muted/45 font-medium [&>tr]:last:border-b-0",t),...s}));et.displayName="TableFooter";const O=i.forwardRef(({className:t,...s},a)=>e.jsx("tr",{ref:a,className:S("border-b border-border/50 transition-all duration-150","hover:bg-primary/5 data-[state=selected]:bg-primary/10","group",t),...s}));O.displayName="TableRow";const p=i.forwardRef(({className:t,...s},a)=>e.jsx("th",{ref:a,className:S("h-12 px-4 text-left align-middle text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/80","[&:has([role=checkbox])]:pr-0",t),...s}));p.displayName="TableHead";const b=i.forwardRef(({className:t,...s},a)=>e.jsx("td",{ref:a,className:S("px-4 py-3.5 align-middle text-sm","[&:has([role=checkbox])]:pr-0","group-hover:text-foreground transition-colors",t),...s}));b.displayName="TableCell";const tt=i.forwardRef(({className:t,...s},a)=>e.jsx("caption",{ref:a,className:S("mt-4 text-sm text-muted-foreground",t),...s}));tt.displayName="TableCaption";const $=15e3,U=6e4,T={requests:"#2563eb",input:"#059669",output:"#ea580c",cacheRead:"#7c3aed",cacheCreation:"#e11d48",latency:"#0891b2"};function D(t,s,a){return t==null?"-":`${t.toLocaleString(void 0,a)} ${s}`}function de(t){if(t==null)return"-";if(t<1024)return`${t} B`;const s=["KB","MB","GB","TB"];let a=t/1024,r=0;for(;a>=1024&&r<s.length-1;)a/=1024,r+=1;return`${a.toFixed(a>=100?0:a>=10?1:2)} ${s[r]}`}function st(t){return t==null?"-":`${t.toLocaleString(void 0,{maximumFractionDigits:t>=10?0:1})}%`}function at(){return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:Array.from({length:6}).map((t,s)=>e.jsx(Xe,{},s))}),e.jsx("div",{className:"grid gap-6 lg:grid-cols-2",children:Array.from({length:4}).map((t,s)=>e.jsx(Ze,{},s))}),e.jsx("div",{className:"rounded-lg border border-border",children:e.jsx("table",{className:"w-full",children:e.jsx("tbody",{children:Array.from({length:5}).map((t,s)=>e.jsx(Je,{columns:6},s))})})})]})}function rt({dbSizeDisplay:t,memoryDisplay:s,selectedEndpointLabel:a,status:r,todayRequests:l}){const{t:o}=C();return e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.4fr)_minmax(320px,0.9fr)]",children:[e.jsx(B,{children:e.jsx(F,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"max-w-2xl space-y-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-primary/20 bg-accent px-3 py-1 text-xs font-semibold text-primary",children:[e.jsx(ie,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Live Gateway"]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:a}),e.jsx("p",{className:"max-w-xl text-sm text-muted-foreground",children:o("dashboard.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(E,{variant:"outline",className:"border-[hsl(var(--success)/0.3)] bg-[hsl(var(--success-bg))] text-[hsl(var(--success)/1)]",children:o("dashboard.status.listeningLabel")}),e.jsx(E,{variant:"secondary",children:a}),e.jsxs(E,{variant:"outline",children:[o("dashboard.labels.todayRequests"),": ",l.toLocaleString()]})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3 lg:min-w-[420px] lg:flex-1",children:[e.jsx(I,{icon:e.jsx(qe,{className:"h-4 w-4","aria-hidden":"true"}),label:o("dashboard.labels.activeRequests"),value:((r==null?void 0:r.activeRequests)??0).toLocaleString()}),e.jsx(I,{icon:e.jsx(K,{className:"h-4 w-4","aria-hidden":"true"}),label:o("dashboard.labels.requestsPerMinute"),value:((r==null?void 0:r.requestsPerMinute)??0).toLocaleString()}),e.jsx(I,{icon:e.jsx(ce,{className:"h-4 w-4","aria-hidden":"true"}),label:o("dashboard.labels.outputTokensPerMinute"),value:((r==null?void 0:r.outputTokensPerMinute)??0).toLocaleString()}),e.jsx(I,{icon:e.jsx(Pe,{className:"h-4 w-4","aria-hidden":"true"}),label:o("dashboard.labels.cpu"),value:st(r==null?void 0:r.cpuUsagePercent)}),e.jsx(I,{icon:e.jsx(me,{className:"h-4 w-4","aria-hidden":"true"}),label:o("dashboard.labels.database"),value:t}),e.jsx(I,{icon:e.jsx(Me,{className:"h-4 w-4","aria-hidden":"true"}),label:o("dashboard.labels.memory"),value:s})]})]})})}),e.jsx(B,{children:e.jsx(F,{className:"pt-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Gateway runtime"}),e.jsxs("p",{className:"mt-1.5 text-xl font-semibold text-foreground",children:[(r==null?void 0:r.host)??"0.0.0.0",":",(r==null?void 0:r.port)??"-"]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(A,{label:o("dashboard.labels.providers"),value:((r==null?void 0:r.providers)??0).toLocaleString()}),e.jsx(A,{label:o("dashboard.labels.activeClientAddresses"),value:((r==null?void 0:r.activeClientAddresses)??0).toLocaleString()}),e.jsx(A,{label:o("dashboard.labels.activeClientSessions"),value:((r==null?void 0:r.activeClientSessions)??0).toLocaleString()}),e.jsx(A,{label:o("dashboard.labels.uniqueClientAddressesLastHour"),value:((r==null?void 0:r.uniqueClientAddressesLastHour)??0).toLocaleString()}),e.jsx(A,{label:o("dashboard.labels.uniqueClientSessionsLastHour"),value:((r==null?void 0:r.uniqueClientSessionsLastHour)??0).toLocaleString()})]})]})})})]})}function ot({overview:t}){const{t:s}=C();return e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(q,{icon:e.jsx(K,{className:"h-5 w-5"}),title:s("dashboard.cards.todayRequests"),value:(t==null?void 0:t.today.requests)??0,suffix:s("common.units.request"),iconClass:"bg-blue-50 text-blue-600 dark:bg-blue-950 dark:text-blue-400"}),e.jsx(q,{icon:e.jsx(Ae,{className:"h-5 w-5"}),title:s("dashboard.cards.todayInput"),value:(t==null?void 0:t.today.inputTokens)??0,suffix:s("common.units.token"),iconClass:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400"}),e.jsx(q,{icon:e.jsx(ce,{className:"h-5 w-5"}),title:s("dashboard.cards.todayCacheRead"),value:(t==null?void 0:t.today.cacheReadTokens)??0,suffix:s("common.units.token"),iconClass:"bg-violet-50 text-violet-600 dark:bg-violet-950 dark:text-violet-400"}),e.jsx(q,{icon:e.jsx(ie,{className:"h-5 w-5"}),title:s("dashboard.cards.todayCacheCreation"),value:(t==null?void 0:t.today.cacheCreationTokens)??0,suffix:s("common.units.token"),iconClass:"bg-rose-50 text-rose-600 dark:bg-rose-950 dark:text-rose-400"}),e.jsx(q,{icon:e.jsx(Q,{className:"h-5 w-5"}),title:s("dashboard.cards.todayOutput"),value:(t==null?void 0:t.today.outputTokens)??0,suffix:s("common.units.token"),iconClass:"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-400"}),e.jsx(q,{icon:e.jsx(De,{className:"h-5 w-5"}),title:s("dashboard.cards.avgLatency"),value:(t==null?void 0:t.today.avgLatencyMs)??0,suffix:s("common.units.ms"),iconClass:"bg-cyan-50 text-cyan-600 dark:bg-cyan-950 dark:text-cyan-400"})]})}function nt({busiestDay:t,fastestTtftModel:s,topModel:a,totalRequestsInRange:r}){const{t:l}=C();return e.jsxs("div",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsx(G,{label:l("dashboard.insights.totalRequests"),value:r.toLocaleString(),hint:l("dashboard.insights.totalRequestsHint")}),e.jsx(G,{label:l("dashboard.insights.busiestDay"),value:t?t.date:"-",hint:t?l("dashboard.insights.busiestDayHint",{value:t.requestCount.toLocaleString()}):l("common.noData")}),e.jsx(G,{label:l("dashboard.insights.topModel"),value:a?`${a.provider}/${a.model}`:"-",hint:a?l("dashboard.insights.topModelHint",{value:a.requests.toLocaleString()}):l("common.noData")}),e.jsx(G,{label:l("dashboard.insights.fastestTtft"),value:s?`${s.provider}/${s.model}`:"-",hint:s?D(s.avgTtftMs,l("common.units.ms")):l("common.noData")})]})}function lt({dailyEmpty:t,dailyOption:s,dailyPending:a,models:r,modelRequestsOption:l,modelUsagePending:o,ttftOption:m,tpotOption:R}){const{t:d}=C();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(H,{title:d("dashboard.charts.requestsTitle"),description:d("dashboard.charts.requestsDesc"),loading:a,option:s,empty:t,emptyText:d("dashboard.charts.empty")}),e.jsx(H,{title:d("dashboard.charts.modelTitle"),description:d("dashboard.charts.modelDesc"),loading:o,option:l,empty:!r.length,emptyText:d("dashboard.charts.empty")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(H,{title:d("dashboard.charts.ttftTitle"),description:d("dashboard.charts.ttftDesc"),loading:o,option:m,empty:!r.some(c=>c.avgTtftMs!=null&&c.avgTtftMs>0),emptyText:d("dashboard.charts.ttftEmpty")}),e.jsx(H,{title:d("dashboard.charts.tpotTitle"),description:d("dashboard.charts.tpotDesc"),loading:o,option:R,empty:!r.some(c=>c.avgTpotMs!=null&&c.avgTpotMs>0),emptyText:d("dashboard.charts.tpotEmpty")})]})]})}function dt({models:t,loading:s}){const{t:a}=C();return e.jsx(he,{title:a("dashboard.modelTable.title"),description:a("dashboard.modelTable.description"),children:s?e.jsx(Y,{compact:!0,label:a("common.loadingShort")}):t.length===0?e.jsx(z,{compact:!0,icon:e.jsx(Q,{className:"h-5 w-5","aria-hidden":"true"}),title:a("dashboard.modelTable.empty")}):e.jsx("div",{className:"overflow-auto rounded-lg border border-border",children:e.jsxs(X,{children:[e.jsx(Z,{children:e.jsxs(O,{children:[e.jsx(p,{children:a("dashboard.modelTable.columns.model")}),e.jsx(p,{className:"text-right",children:a("dashboard.modelTable.columns.requests")}),e.jsx(p,{className:"text-right",children:a("dashboard.modelTable.columns.latency")}),e.jsx(p,{className:"text-right",children:a("dashboard.modelTable.columns.ttft")}),e.jsx(p,{className:"text-right",children:a("dashboard.modelTable.columns.tpot")})]})}),e.jsx(J,{children:t.map(r=>e.jsxs(O,{children:[e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:r.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:r.model})]})}),e.jsx(b,{className:"text-right font-medium",children:r.requests.toLocaleString()}),e.jsx(b,{className:"text-right",children:D(r.avgLatencyMs,a("common.units.ms"))}),e.jsx(b,{className:"text-right",children:D(r.avgTtftMs,a("common.units.ms"))}),e.jsx(b,{className:"text-right",children:D(r.avgTpotMs,a("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${r.provider}/${r.model}`))})]})})})}function it({records:t,loading:s}){const{t:a}=C(),r=t.filter(o=>!o.error&&(o.status_code??200)<400).length,l=t.filter(o=>o.error||(o.status_code??200)>=400).length;return e.jsx(he,{title:a("dashboard.recent.title"),description:a("dashboard.recent.subtitle",{count:5}),actions:t.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(E,{variant:"secondary",children:t.length}),e.jsxs(E,{variant:"outline",className:"border-[hsl(var(--success)/0.3)] bg-[hsl(var(--success-bg))] text-[hsl(var(--success)/1)]",children:[a("common.status.success"),": ",r]}),e.jsxs(E,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[a("common.status.error"),": ",l]})]}):null,children:s?e.jsx(Y,{compact:!0,label:a("dashboard.recent.loading")}):t.length===0?e.jsx(z,{compact:!0,icon:e.jsx(K,{className:"h-5 w-5","aria-hidden":"true"}),title:a("dashboard.recent.empty")}):e.jsx("div",{className:"overflow-auto rounded-lg border border-border",children:e.jsxs(X,{children:[e.jsx(Z,{children:e.jsxs(O,{children:[e.jsx(p,{children:a("dashboard.recent.columns.time")}),e.jsx(p,{children:a("dashboard.recent.columns.endpoint")}),e.jsx(p,{children:a("dashboard.recent.columns.provider")}),e.jsx(p,{children:a("dashboard.recent.columns.route")}),e.jsx(p,{className:"text-right",children:a("dashboard.recent.columns.latency")}),e.jsx(p,{children:a("dashboard.recent.columns.status")})]})}),e.jsx(J,{children:t.map(o=>e.jsxs(O,{children:[e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium",children:new Date(o.timestamp).toLocaleString()}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["#",o.id]})]})}),e.jsx(b,{children:e.jsx(E,{variant:"outline",className:"text-[11px]",children:o.endpoint==="anthropic"?a("logs.endpointAnthropic"):o.endpoint==="openai"?a("logs.endpointOpenAI"):o.endpoint})}),e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:o.provider}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:o.stream?"stream":"sync"})]})}),e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx("span",{children:o.client_model??a("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"->"}),e.jsx("span",{className:"font-medium text-foreground",children:o.model})]}),o.error?e.jsx("span",{className:"truncate text-destructive",children:o.error}):null]})}),e.jsx(b,{className:"text-right font-medium",children:D(o.latency_ms,a("common.units.ms"))}),e.jsx(b,{children:e.jsx(E,{variant:o.error?"destructive":"default",className:"min-w-14 justify-center",children:(o.status_code??(o.error?500:200)).toString()})})]},o.id))})]})})})}function I({icon:t,label:s,value:a}){return e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-primary/10 text-primary",children:t}),s]}),e.jsx("p",{className:"mt-2 text-lg font-semibold text-foreground",children:a})]})}function A({label:t,value:s}){return e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2.5",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-foreground",children:s})]})}function q({icon:t,iconClass:s,suffix:a,title:r,value:l}){return e.jsx(B,{children:e.jsxs(F,{className:"pt-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:r}),t?e.jsx("div",{className:S("flex h-9 w-9 items-center justify-center rounded-lg",s),children:t}):null]}),e.jsxs("p",{className:"mt-3 text-2xl font-bold text-foreground",children:[l.toLocaleString(),a?e.jsx("span",{className:"ml-1.5 text-sm font-normal text-muted-foreground",children:a}):null]})]})})}function G({label:t,value:s,hint:a}){return e.jsx(B,{children:e.jsxs(F,{className:"pt-4",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:t}),e.jsx("p",{className:"mt-2 line-clamp-1 text-sm font-semibold text-foreground",children:s}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a})]})})}function H({description:t,empty:s,emptyText:a,loading:r,option:l,title:o}){const{t:m}=C();return e.jsx(B,{children:e.jsxs(F,{className:"space-y-4 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:o}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:t})]}),r?e.jsx(Y,{compact:!0,className:"min-h-[320px]",label:m("common.loadingShort")}):s?e.jsx(z,{compact:!0,className:"min-h-[320px]",icon:e.jsx(Q,{className:"h-5 w-5","aria-hidden":"true"}),title:a??m("dashboard.charts.empty")}):e.jsx(Ye,{echarts:We,option:l,className:"h-[40vh] min-h-[280px] max-h-[420px]",notMerge:!0,lazyUpdate:!0})]})})}function ct(){var W,ee,te,se,ae,re,oe,ne;const{t}=C(),{pushToast:s}=_e(),[a,r]=$e(Qe.dashboard.endpointFilter,"all"),[l,o]=i.useState(!1),m=a==="all"?void 0:a,R=w(L.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:U,refetchIntervalInBackground:!0}),d=w(L.stats.overview(a),{url:"/api/stats/overview",method:"GET",params:m?{endpoint:m}:void 0},{refetchInterval:$,refetchIntervalInBackground:!0}),c=w(L.stats.daily(14,a),{url:"/api/stats/daily",method:"GET",params:{days:14,...m?{endpoint:m}:{}}},{refetchInterval:U,refetchIntervalInBackground:!0}),y=w(L.stats.model(7,6,a),{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...m?{endpoint:m}:{}}},{refetchInterval:U,refetchIntervalInBackground:!0}),g=w(L.status.byEndpoint(a),{url:"/api/status",method:"GET",params:m?{endpoint:m}:void 0},{refetchInterval:$,refetchIntervalInBackground:!0}),x=w(L.db.info(),{url:"/api/db/info",method:"GET"},{refetchInterval:$,refetchIntervalInBackground:!0}),N=w(L.logs.recent(a),{url:"/api/logs",method:"GET",params:{limit:5,...m?{endpoint:m}:{}}},{refetchInterval:$,refetchIntervalInBackground:!0});i.useEffect(()=>{d.isError&&d.error&&s({title:t("dashboard.toast.overviewError"),description:d.error.message,variant:"error"})},[d.error,d.isError,s,t]),i.useEffect(()=>{c.isError&&c.error&&s({title:t("dashboard.toast.dailyError"),description:c.error.message,variant:"error"})},[c.error,c.isError,s,t]),i.useEffect(()=>{y.isError&&y.error&&s({title:t("dashboard.toast.modelError"),description:y.error.message,variant:"error"})},[y.error,y.isError,s,t]),i.useEffect(()=>{g.isError&&g.error&&s({title:t("dashboard.toast.statusError"),description:g.error.message,variant:"error"})},[g.error,g.isError,s,t]),i.useEffect(()=>{x.isError&&x.error&&s({title:t("dashboard.toast.dbError"),description:x.error.message,variant:"error"})},[x.error,x.isError,s,t]),i.useEffect(()=>{N.isError&&N.error&&s({title:t("dashboard.toast.recentError"),description:N.error.message,variant:"error"})},[N.error,N.isError,s,t]);const ue=i.useCallback(async()=>{await Promise.all([R.refetch(),d.refetch(),c.refetch(),y.refetch(),g.refetch(),x.refetch(),N.refetch()])},[R,x,c,N,y,d,g]),xe=i.useCallback(async()=>{if(!l){o(!0);try{await Ge.post("/api/db/compact"),await x.refetch(),s({title:t("dashboard.toast.compactSuccess.title"),description:t("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(n){const h=He(n);s({title:t("dashboard.toast.compactError.title"),description:h.message,variant:"error"})}finally{o(!1)}}},[l,x,s,t]),pe=d.data,v=c.data??[],u=y.data??[],be=g.data,k=x.data,ge=((W=N.data)==null?void 0:W.items)??[],fe=a==="all"?t("dashboard.filters.endpointAll"):a==="anthropic"?t("dashboard.filters.endpointAnthropic"):a==="openai"?t("dashboard.filters.endpointOpenAI"):((se=(te=(ee=R.data)==null?void 0:ee.endpoints)==null?void 0:te.find(n=>n.id===a))==null?void 0:se.label)||a,je=v.reduce((n,h)=>n+h.requestCount,0),ye=v.reduce((n,h)=>!n||h.requestCount>n.requestCount?h:n,null),Ne=u[0],ve=u.filter(n=>n.avgTtftMs!=null&&n.avgTtftMs>0).sort((n,h)=>(n.avgTtftMs??Number.POSITIVE_INFINITY)-(h.avgTtftMs??Number.POSITIVE_INFINITY))[0],Te=R.isFetching||d.isFetching||c.isFetching||y.isFetching||g.isFetching||x.isFetching||N.isFetching,Se=d.isPending||g.isPending||x.isPending,Ce=((ae=d.error)==null?void 0:ae.message)??((re=g.error)==null?void 0:re.message)??((oe=x.error)==null?void 0:oe.message)??null,Ee=k?de(k.totalBytes??k.sizeBytes):"-",Re=de(k==null?void 0:k.memoryRssBytes),ke=i.useMemo(()=>{const n=v.map(j=>j.date),h=t("dashboard.charts.barRequests"),P=t("dashboard.charts.lineInput"),M=t("dashboard.charts.lineOutput"),f=t("dashboard.charts.lineCacheRead"),le=t("dashboard.charts.lineCacheCreation");return{tooltip:{trigger:"axis"},legend:{data:[h,P,M,f,le]},grid:{left:56,right:28,top:56,bottom:54},xAxis:{type:"category",data:n},yAxis:{type:"value"},series:[{name:h,type:"bar",data:v.map(j=>j.requestCount),itemStyle:{color:T.requests,borderRadius:[6,6,0,0]}},{name:P,type:"line",smooth:!0,data:v.map(j=>j.inputTokens),itemStyle:{color:T.input},lineStyle:{width:2}},{name:M,type:"line",smooth:!0,data:v.map(j=>j.outputTokens),itemStyle:{color:T.output},lineStyle:{width:2}},{name:f,type:"line",smooth:!0,data:v.map(j=>j.cacheReadTokens),itemStyle:{color:T.cacheRead},lineStyle:{width:2}},{name:le,type:"line",smooth:!0,data:v.map(j=>j.cacheCreationTokens),itemStyle:{color:T.cacheCreation},lineStyle:{width:2}}]}},[v,t]),we=i.useMemo(()=>{const n=u.map(f=>`${f.provider}/${f.model}`),h=t("dashboard.charts.barRequests"),P=t("dashboard.charts.lineInput"),M=t("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis"},legend:{data:[h,P,M]},grid:{left:72,right:52,top:56,bottom:96},xAxis:{type:"category",data:n,axisLabel:{rotate:28}},yAxis:[{type:"value",name:h},{type:"value",name:t("dashboard.charts.axisTokens"),position:"right"}],series:[{name:h,type:"bar",data:u.map(f=>f.requests),itemStyle:{color:T.requests,borderRadius:[6,6,0,0]}},{name:P,type:"line",yAxisIndex:1,smooth:!0,data:u.map(f=>f.inputTokens??0),itemStyle:{color:T.input}},{name:M,type:"line",yAxisIndex:1,smooth:!0,data:u.map(f=>f.outputTokens??0),itemStyle:{color:T.output}}]}},[u,t]),Le=i.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:u.map(n=>`${n.provider}/${n.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:t("dashboard.charts.ttftAxis")},series:[{name:t("dashboard.charts.ttftLabel"),type:"bar",data:u.map(n=>n.avgTtftMs??0),itemStyle:{color:T.latency,borderRadius:[6,6,0,0]}}]}),[u,t]),Ie=i.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:u.map(n=>`${n.provider}/${n.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:t("dashboard.charts.tpotAxis")},series:[{name:t("dashboard.charts.tpotLabel"),type:"bar",data:u.map(n=>n.avgTpotMs??0),itemStyle:{color:T.output,borderRadius:[6,6,0,0]}}]}),[u,t]);return{compacting:l,customEndpoints:((ne=R.data)==null?void 0:ne.endpoints)??[],daily:v,dailyOption:ke,dailyPending:c.isPending,dbInfo:k,dbSizeDisplay:Ee,endpointFilter:a,fastestTtftModel:ve,handleCompact:xe,handleRefresh:ue,bootstrapError:Ce,isBootstrapping:Se,isRefreshing:Te,latestLogsPending:N.isPending,memoryDisplay:Re,modelRequestsOption:we,modelUsagePending:y.isPending,models:u,overview:pe,recentLogs:ge,selectedEndpointLabel:fe,setEndpointFilter:r,status:be,topModel:Ne,totalRequestsInRange:je,busiestDay:ye,ttftOption:Le,tpotOption:Ie}}function Lt(){var a;const{t}=C(),s=ct();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Oe,{icon:e.jsx(Q,{className:"h-5 w-5","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description"),badge:s.selectedEndpointLabel,eyebrow:"Operations",breadcrumb:"Gateway / Dashboard",helper:t("dashboard.charts.requestsDesc"),actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:items-center sm:justify-end",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:[t("dashboard.filters.endpoint")," · ",s.selectedEndpointLabel]}),e.jsxs(ze,{value:s.endpointFilter,onValueChange:s.setEndpointFilter,children:[e.jsx(Ve,{className:"w-full sm:w-[168px]",children:e.jsx(Ue,{})}),e.jsxs(Ke,{children:[e.jsx(_,{value:"all",children:t("dashboard.filters.endpointAll")}),e.jsx(_,{value:"anthropic",children:t("dashboard.filters.endpointAnthropic")}),e.jsx(_,{value:"openai",children:t("dashboard.filters.endpointOpenAI")}),s.customEndpoints.map(r=>e.jsx(_,{value:r.id,children:r.label||r.id},r.id))]})]}),e.jsxs(V,{variant:"outline",size:"sm",onClick:()=>void s.handleRefresh(),disabled:s.isRefreshing,className:"w-full sm:w-auto",children:[e.jsx(Be,{className:S("mr-2 h-4 w-4",s.isRefreshing&&"animate-spin"),"aria-hidden":"true"}),s.isRefreshing?t("common.actions.refreshing"):t("common.actions.refresh")]}),e.jsxs(V,{variant:"outline",size:"sm",onClick:()=>void s.handleCompact(),disabled:s.compacting,className:"w-full sm:w-auto",children:[e.jsx(me,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),s.compacting?t("dashboard.actions.compacting"):t("dashboard.actions.compact")]})]})}),s.isBootstrapping?e.jsx(at,{}):s.bootstrapError?e.jsx(z,{icon:e.jsx(Fe,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:t("common.status.error"),description:s.bootstrapError,action:e.jsx(V,{variant:"outline",onClick:()=>void s.handleRefresh(),children:t("common.actions.refresh")})}):e.jsxs(e.Fragment,{children:[e.jsx(rt,{dbSizeDisplay:s.dbSizeDisplay,memoryDisplay:s.memoryDisplay,selectedEndpointLabel:s.selectedEndpointLabel,status:s.status,todayRequests:((a=s.overview)==null?void 0:a.today.requests)??0}),e.jsx(ot,{overview:s.overview}),e.jsx(nt,{busiestDay:s.busiestDay,fastestTtftModel:s.fastestTtftModel,topModel:s.topModel,totalRequestsInRange:s.totalRequestsInRange}),e.jsx(lt,{dailyEmpty:!s.daily.length,dailyOption:s.dailyOption,dailyPending:s.dailyPending,models:s.models,modelRequestsOption:s.modelRequestsOption,modelUsagePending:s.modelUsagePending,ttftOption:s.ttftOption,tpotOption:s.tpotOption}),e.jsx(dt,{models:s.models,loading:s.modelUsagePending}),e.jsx(it,{records:s.recentLogs,loading:s.latestLogsPending})]})]})}export{Lt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as t,a8 as g}from"./vendor-
|
|
1
|
+
import{r,j as t,a8 as g}from"./vendor-5iCEqDpV.js";import{F as u,G as n,H as d,J as b,K as l,M as y,O as i}from"./radix-CmyU-WBH.js";import{c as o}from"./index-BzuBtvAC.js";const k=u,N=b,c=r.forwardRef(({className:a,...e},s)=>t.jsx(i,{ref:s,className:o("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...e}));c.displayName=i.displayName;const p=r.forwardRef(({className:a,children:e,...s},x)=>t.jsxs(N,{children:[t.jsx(c,{}),t.jsxs(l,{ref:x,className:o("fixed left-[50%] top-[50%] z-50 flex max-h-[85vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",a),...s,children:[e,t.jsxs(y,{className:"absolute right-4 top-4 rounded-2xl border border-transparent p-2 opacity-70 ring-offset-background transition-all hover:border-border hover:bg-accent hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(g,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));p.displayName=l.displayName;const m=({className:a,...e})=>t.jsx("div",{className:o("flex shrink-0 flex-col space-y-1.5 text-center sm:text-left",a),...e});m.displayName="DialogHeader";const f=({className:a,...e})=>t.jsx("div",{className:o("flex shrink-0 flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...e});f.displayName="DialogFooter";const j=r.forwardRef(({className:a,...e},s)=>t.jsx(n,{ref:s,className:o("text-lg font-semibold leading-none tracking-[-0.02em]",a),...e}));j.displayName=n.displayName;const h=r.forwardRef(({className:a,...e},s)=>t.jsx(d,{ref:s,className:o("text-sm leading-6 text-muted-foreground",a),...e}));h.displayName=d.displayName;function R({children:a,className:e}){return t.jsx(p,{className:o("gap-0 overflow-hidden p-0",e),children:a})}function A({children:a,className:e}){return t.jsx("div",{className:o("border-b border-border bg-secondary px-6 py-5",e),children:t.jsx(m,{children:a})})}function C({children:a,className:e}){return t.jsx("div",{className:o("min-h-0 overflow-y-auto px-6 py-5",e),children:a})}function z({children:a,className:e}){return t.jsx(f,{className:o("border-t border-border bg-secondary px-6 py-4",e),children:a})}export{R as A,k as D,A as a,j as b,h as c,C as d,z as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as a}from"./charts-react-DJ_0LNAP.js";import{u as s,i as l,a as t,b as i,c as n,d as o,f as r,g as $}from"./charts-core-C-3-Lo7l.js";s([l,t,i,n,o,r,$]);const e=a;export{e as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as f,j as e,aj as R,an as M,ao as I,V as T,ap as V,aq as q,ar as B,a1 as D}from"./vendor-CjJPKsTb.js";import{P as K}from"./PageHeader-DWkUnwoU.js";import{P as G}from"./PageSection-9-z2ysug.js";import{P as Q,a as $}from"./PageState-5sxEzXut.js";import{u as H}from"./useApiQuery-CCy5_Mc8.js";import{u as J,B as x,c as p}from"./index-BiTh8byX.js";import{q as O}from"./queryKeys-BMvyDTQS.js";import{B as c}from"./badge-tREH_88e.js";import{C as N,a as y}from"./card-yK3LQB_K.js";import{I as U}from"./input-CXrASgDm.js";import{S as _,a as W,b as X,c as Y,d as g}from"./select-DH6I1mKJ.js";import{u as z}from"./i18n-CfLThlXq.js";import"./query-D3IfCUhp.js";import"./router-CmaL1NgV.js";import"./radix-54BMi3RD.js";function Z(s){const a=Date.now()-s,n=Math.abs(a),t=60*1e3,m=60*t,u=24*m;if(n<t){const o=Math.max(Math.round(n/1e3),1);return a>=0?`${o}s ago`:`in ${o}s`}if(n<m){const o=Math.round(n/t);return a>=0?`${o}m ago`:`in ${o}m`}if(n<u){const o=Math.round(n/m);return a>=0?`${o}h ago`:`in ${o}h`}const l=Math.round(n/u);return a>=0?`${l}d ago`:`in ${l}d`}function ee(s){return new Date(s).toLocaleString()}const se={info:"secondary",warn:"outline",error:"destructive"};function pe(){var L,A,P;const{t:s}=z(),{pushToast:i}=J(),[a,n]=f.useState(null),[t,m]=f.useState({level:"",type:""}),u=f.useMemo(()=>({limit:50,cursor:a??void 0,level:t.level||void 0,type:t.type.trim()||void 0}),[a,t.level,t.type]),l=H(O.events.list(u),{url:"/api/events",method:"GET",params:u});f.useEffect(()=>{l.isError&&l.error&&i({title:s("events.toast.loadFailure",{message:l.error.message}),variant:"error"})},[l.error,l.isError,i,s]);const o=()=>{n(null),m({level:"",type:""})},d=((L=l.data)==null?void 0:L.events)??[],k=((A=l.data)==null?void 0:A.nextCursor)??null,F=l.isLoading,j=l.isFetching&&!l.isLoading,h=f.useMemo(()=>{const r=[];return t.level&&r.push(s(`events.levels.${t.level}`)),t.type.trim()&&r.push(t.type.trim()),r},[t.level,t.type,s]),C=d.filter(r=>r.level==="info").length,S=d.filter(r=>r.level==="warn").length,E=d.filter(r=>r.level==="error").length;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(K,{icon:e.jsx(M,{className:"h-5 w-5","aria-hidden":"true"}),title:s("events.title"),description:s("events.description"),eyebrow:"Audit",breadcrumb:"Gateway / Events",helper:s("events.filters.title"),badge:d.length>0?`${d.length} events`:void 0,actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:s(a?"events.actions.older":"events.actions.newest")}),e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),disabled:j,className:"w-full sm:w-auto",children:[e.jsx(R,{className:p("mr-2 h-4 w-4",j&&"animate-spin"),"aria-hidden":"true"}),s(j?"common.actions.refreshing":"common.actions.refresh")]})]})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(w,{icon:e.jsx(I,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.info"),value:C.toLocaleString(),tone:"emerald"}),e.jsx(w,{icon:e.jsx(T,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.warn"),value:S.toLocaleString(),tone:"amber"}),e.jsx(w,{icon:e.jsx(V,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.error"),value:E.toLocaleString(),tone:"rose"})]}),e.jsx(N,{"data-testid":"events-filters-card",className:"overflow-hidden",children:e.jsx(y,{className:"pt-5",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[e.jsx(q,{className:"h-4 w-4 text-primary","aria-hidden":"true"}),s("events.filters.title"),e.jsx(c,{variant:"outline",children:d.length})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("events.description")})]}),e.jsxs("div",{className:"grid gap-2 sm:flex sm:flex-wrap sm:items-center",children:[h.length>0?e.jsx(x,{variant:"ghost",size:"sm",onClick:o,className:"w-full sm:w-auto",children:s("common.actions.reset")}):null,e.jsxs(x,{variant:"outline",size:"sm",disabled:!a,onClick:()=>n(null),className:"w-full sm:w-auto",children:[e.jsx(B,{className:"mr-1 h-4 w-4","aria-hidden":"true"}),s("events.actions.newest")]}),e.jsxs(x,{variant:"outline",size:"sm",disabled:!k,onClick:()=>n(k),className:"w-full sm:w-auto",children:[s("events.actions.older"),e.jsx(D,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:flex-wrap md:items-center",children:[e.jsxs(_,{value:t.level,onValueChange:r=>{n(null),m(b=>({...b,level:r==="all"?"":r}))},children:[e.jsx(W,{className:"w-full md:w-[160px]",children:e.jsx(X,{placeholder:s("events.filters.allLevels")})}),e.jsxs(Y,{children:[e.jsx(g,{value:"all",children:s("events.filters.allLevels")}),e.jsx(g,{value:"info",children:s("events.levels.info")}),e.jsx(g,{value:"warn",children:s("events.levels.warn")}),e.jsx(g,{value:"error",children:s("events.levels.error")})]})]}),e.jsx(U,{className:"w-full md:w-[220px]",placeholder:s("events.filters.typePlaceholder"),value:t.type,onChange:r=>{n(null),m(b=>({...b,type:r.target.value}))}}),e.jsx(x,{variant:"ghost",size:"sm",onClick:o,disabled:h.length===0,className:"w-full md:w-auto",children:s("common.actions.reset")})]}),h.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(r=>e.jsx(c,{variant:"secondary",children:r},r))}):null]})})}),e.jsx(G,{title:s("events.title"),description:s(a?"events.actions.older":"events.actions.newest"),actions:d.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(c,{variant:"outline",className:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-800 dark:bg-blue-950/30 dark:text-blue-300",children:[s("events.levels.info"),": ",C]}),e.jsxs(c,{variant:"outline",className:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:[s("events.levels.warn"),": ",S]}),e.jsxs(c,{variant:"outline",className:"border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-300",children:[s("events.levels.error"),": ",E]})]}):null,children:F?e.jsx(Q,{label:s("common.loading")}):l.isError?e.jsx($,{icon:e.jsx(T,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:s("events.toast.loadFailure",{message:((P=l.error)==null?void 0:P.message)??s("common.unknownError")}),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),children:s("common.actions.refresh")})}):d.length===0?e.jsx($,{icon:e.jsx(M,{className:"h-5 w-5","aria-hidden":"true"}),tone:"primary",title:s("events.empty.title"),description:s("events.empty.subtitle"),action:h.length>0?e.jsx(x,{variant:"outline",size:"sm",onClick:o,children:s("common.actions.reset")}):void 0}):e.jsx("div",{className:"grid gap-4",children:d.map(r=>e.jsx(re,{event:r},r.id))})})]})}function w({icon:s,title:i,tone:a,value:n}){const t={emerald:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400",amber:"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-400",rose:"bg-rose-50 text-rose-600 dark:bg-rose-950 dark:text-rose-400"}[a];return e.jsx(N,{children:e.jsxs(y,{className:"flex items-center justify-between gap-3 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:i}),e.jsx("p",{className:"mt-2 text-3xl font-bold tracking-tight text-foreground",children:n})]}),e.jsx("div",{className:p("flex h-11 w-11 items-center justify-center rounded-xl",t),children:s})]})})}function re({event:s}){const{t:i}=z(),a=s.level==="error"?"border-l-destructive":s.level==="warn"?"border-l-amber-500":"border-l-emerald-500";return e.jsx(N,{className:p("overflow-hidden border-l-4",a),children:e.jsxs(y,{className:"space-y-4 pt-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-start xl:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(c,{variant:se[s.level]||"secondary",children:i(`events.levels.${s.level}`)}),e.jsxs(c,{variant:"outline",children:["#",s.id]}),s.mode?e.jsx(c,{variant:"secondary",children:s.mode}):null,s.endpoint?e.jsx(c,{variant:"outline",children:s.endpoint}):null]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold tracking-[-0.01em]",children:s.title||i("events.defaultTitle")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.message||i("events.defaultMessage")})]})]}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground xl:text-right",children:[e.jsx("p",{children:ee(s.createdAt)}),e.jsx("p",{children:Z(s.createdAt)})]})]}),e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(v,{label:"Type",value:s.type}),e.jsx(v,{label:"Source",value:s.source}),e.jsx(v,{label:"IP",value:s.ipAddress}),e.jsx(v,{label:"API Key",value:s.apiKeyName}),e.jsx(v,{label:"User Agent",value:s.userAgent,wide:!0})]}),s.details?e.jsxs("details",{className:"rounded-lg border border-border bg-secondary p-3 text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-primary",children:i("events.details")}),e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-lg border border-border bg-card p-3 text-xs leading-6",children:JSON.stringify(s.details,null,2)})]}):null]})})}function v({label:s,value:i,wide:a=!1}){return i?e.jsxs("div",{className:p("rounded-lg border border-border bg-secondary px-3 py-3",a&&"sm:col-span-2 xl:col-span-2"),children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 break-all text-sm text-foreground",children:i})]}):null}export{pe as default};
|
|
1
|
+
import{r as f,j as e,aj as R,an as M,ao as I,V as T,ap as V,aq as q,ar as B,a1 as D}from"./vendor-5iCEqDpV.js";import{P as K}from"./PageHeader-CSF0BWul.js";import{P as G}from"./PageSection-Bp_SuEp0.js";import{P as Q,a as $}from"./PageState-BeXrzVEe.js";import{u as H}from"./useApiQuery-fBWRSgFK.js";import{u as J,B as x,c as p}from"./index-BzuBtvAC.js";import{q as O}from"./queryKeys-BMvyDTQS.js";import{B as c}from"./badge-BvMdmUqJ.js";import{C as N,a as y}from"./card-CjhYPqKk.js";import{I as U}from"./input-BnFZKjRM.js";import{S as _,a as W,b as X,c as Y,d as g}from"./select-KdDvaKo4.js";import{u as z}from"./i18n-C7VVFIdN.js";import"./query-DxhDvnDC.js";import"./router-D8u_RlVh.js";import"./radix-CmyU-WBH.js";function Z(s){const a=Date.now()-s,n=Math.abs(a),t=60*1e3,m=60*t,u=24*m;if(n<t){const o=Math.max(Math.round(n/1e3),1);return a>=0?`${o}s ago`:`in ${o}s`}if(n<m){const o=Math.round(n/t);return a>=0?`${o}m ago`:`in ${o}m`}if(n<u){const o=Math.round(n/m);return a>=0?`${o}h ago`:`in ${o}h`}const l=Math.round(n/u);return a>=0?`${l}d ago`:`in ${l}d`}function ee(s){return new Date(s).toLocaleString()}const se={info:"secondary",warn:"outline",error:"destructive"};function pe(){var L,A,P;const{t:s}=z(),{pushToast:i}=J(),[a,n]=f.useState(null),[t,m]=f.useState({level:"",type:""}),u=f.useMemo(()=>({limit:50,cursor:a??void 0,level:t.level||void 0,type:t.type.trim()||void 0}),[a,t.level,t.type]),l=H(O.events.list(u),{url:"/api/events",method:"GET",params:u});f.useEffect(()=>{l.isError&&l.error&&i({title:s("events.toast.loadFailure",{message:l.error.message}),variant:"error"})},[l.error,l.isError,i,s]);const o=()=>{n(null),m({level:"",type:""})},d=((L=l.data)==null?void 0:L.events)??[],k=((A=l.data)==null?void 0:A.nextCursor)??null,F=l.isLoading,j=l.isFetching&&!l.isLoading,h=f.useMemo(()=>{const r=[];return t.level&&r.push(s(`events.levels.${t.level}`)),t.type.trim()&&r.push(t.type.trim()),r},[t.level,t.type,s]),C=d.filter(r=>r.level==="info").length,S=d.filter(r=>r.level==="warn").length,E=d.filter(r=>r.level==="error").length;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(K,{icon:e.jsx(M,{className:"h-5 w-5","aria-hidden":"true"}),title:s("events.title"),description:s("events.description"),eyebrow:"Audit",breadcrumb:"Gateway / Events",helper:s("events.filters.title"),badge:d.length>0?`${d.length} events`:void 0,actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:s(a?"events.actions.older":"events.actions.newest")}),e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),disabled:j,className:"w-full sm:w-auto",children:[e.jsx(R,{className:p("mr-2 h-4 w-4",j&&"animate-spin"),"aria-hidden":"true"}),s(j?"common.actions.refreshing":"common.actions.refresh")]})]})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(w,{icon:e.jsx(I,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.info"),value:C.toLocaleString(),tone:"emerald"}),e.jsx(w,{icon:e.jsx(T,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.warn"),value:S.toLocaleString(),tone:"amber"}),e.jsx(w,{icon:e.jsx(V,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.error"),value:E.toLocaleString(),tone:"rose"})]}),e.jsx(N,{"data-testid":"events-filters-card",className:"overflow-hidden",children:e.jsx(y,{className:"pt-5",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[e.jsx(q,{className:"h-4 w-4 text-primary","aria-hidden":"true"}),s("events.filters.title"),e.jsx(c,{variant:"outline",children:d.length})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("events.description")})]}),e.jsxs("div",{className:"grid gap-2 sm:flex sm:flex-wrap sm:items-center",children:[h.length>0?e.jsx(x,{variant:"ghost",size:"sm",onClick:o,className:"w-full sm:w-auto",children:s("common.actions.reset")}):null,e.jsxs(x,{variant:"outline",size:"sm",disabled:!a,onClick:()=>n(null),className:"w-full sm:w-auto",children:[e.jsx(B,{className:"mr-1 h-4 w-4","aria-hidden":"true"}),s("events.actions.newest")]}),e.jsxs(x,{variant:"outline",size:"sm",disabled:!k,onClick:()=>n(k),className:"w-full sm:w-auto",children:[s("events.actions.older"),e.jsx(D,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:flex-wrap md:items-center",children:[e.jsxs(_,{value:t.level,onValueChange:r=>{n(null),m(b=>({...b,level:r==="all"?"":r}))},children:[e.jsx(W,{className:"w-full md:w-[160px]",children:e.jsx(X,{placeholder:s("events.filters.allLevels")})}),e.jsxs(Y,{children:[e.jsx(g,{value:"all",children:s("events.filters.allLevels")}),e.jsx(g,{value:"info",children:s("events.levels.info")}),e.jsx(g,{value:"warn",children:s("events.levels.warn")}),e.jsx(g,{value:"error",children:s("events.levels.error")})]})]}),e.jsx(U,{className:"w-full md:w-[220px]",placeholder:s("events.filters.typePlaceholder"),value:t.type,onChange:r=>{n(null),m(b=>({...b,type:r.target.value}))}}),e.jsx(x,{variant:"ghost",size:"sm",onClick:o,disabled:h.length===0,className:"w-full md:w-auto",children:s("common.actions.reset")})]}),h.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(r=>e.jsx(c,{variant:"secondary",children:r},r))}):null]})})}),e.jsx(G,{title:s("events.title"),description:s(a?"events.actions.older":"events.actions.newest"),actions:d.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(c,{variant:"outline",className:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-800 dark:bg-blue-950/30 dark:text-blue-300",children:[s("events.levels.info"),": ",C]}),e.jsxs(c,{variant:"outline",className:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:[s("events.levels.warn"),": ",S]}),e.jsxs(c,{variant:"outline",className:"border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-300",children:[s("events.levels.error"),": ",E]})]}):null,children:F?e.jsx(Q,{label:s("common.loading")}):l.isError?e.jsx($,{icon:e.jsx(T,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:s("events.toast.loadFailure",{message:((P=l.error)==null?void 0:P.message)??s("common.unknownError")}),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void l.refetch(),children:s("common.actions.refresh")})}):d.length===0?e.jsx($,{icon:e.jsx(M,{className:"h-5 w-5","aria-hidden":"true"}),tone:"primary",title:s("events.empty.title"),description:s("events.empty.subtitle"),action:h.length>0?e.jsx(x,{variant:"outline",size:"sm",onClick:o,children:s("common.actions.reset")}):void 0}):e.jsx("div",{className:"grid gap-4",children:d.map(r=>e.jsx(re,{event:r},r.id))})})]})}function w({icon:s,title:i,tone:a,value:n}){const t={emerald:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400",amber:"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-400",rose:"bg-rose-50 text-rose-600 dark:bg-rose-950 dark:text-rose-400"}[a];return e.jsx(N,{children:e.jsxs(y,{className:"flex items-center justify-between gap-3 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:i}),e.jsx("p",{className:"mt-2 text-3xl font-bold tracking-tight text-foreground",children:n})]}),e.jsx("div",{className:p("flex h-11 w-11 items-center justify-center rounded-xl",t),children:s})]})})}function re({event:s}){const{t:i}=z(),a=s.level==="error"?"border-l-destructive":s.level==="warn"?"border-l-amber-500":"border-l-emerald-500";return e.jsx(N,{className:p("overflow-hidden border-l-4",a),children:e.jsxs(y,{className:"space-y-4 pt-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-start xl:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(c,{variant:se[s.level]||"secondary",children:i(`events.levels.${s.level}`)}),e.jsxs(c,{variant:"outline",children:["#",s.id]}),s.mode?e.jsx(c,{variant:"secondary",children:s.mode}):null,s.endpoint?e.jsx(c,{variant:"outline",children:s.endpoint}):null]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold tracking-[-0.01em]",children:s.title||i("events.defaultTitle")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.message||i("events.defaultMessage")})]})]}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground xl:text-right",children:[e.jsx("p",{children:ee(s.createdAt)}),e.jsx("p",{children:Z(s.createdAt)})]})]}),e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(v,{label:"Type",value:s.type}),e.jsx(v,{label:"Source",value:s.source}),e.jsx(v,{label:"IP",value:s.ipAddress}),e.jsx(v,{label:"API Key",value:s.apiKeyName}),e.jsx(v,{label:"User Agent",value:s.userAgent,wide:!0})]}),s.details?e.jsxs("details",{className:"rounded-lg border border-border bg-secondary p-3 text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-primary",children:i("events.details")}),e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-lg border border-border bg-card p-3 text-xs leading-6",children:JSON.stringify(s.details,null,2)})]}):null]})})}function v({label:s,value:i,wide:a=!1}){return i?e.jsxs("div",{className:p("rounded-lg border border-border bg-secondary px-3 py-3",a&&"sm:col-span-2 xl:col-span-2"),children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 break-all text-sm text-foreground",children:i})]}):null}export{pe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as u,j as e,aD as b,aA as N,aE as v,aF as y}from"./vendor-
|
|
1
|
+
import{r as u,j as e,aD as b,aA as N,aE as v,aF as y}from"./vendor-5iCEqDpV.js";import{P as w}from"./PageHeader-CSF0BWul.js";import{P as a}from"./PageSection-Bp_SuEp0.js";import{c as h}from"./clipboard-CALi6bTW.js";import{C as p,a as j}from"./card-CjhYPqKk.js";import{B as f}from"./index-BzuBtvAC.js";import{u as x}from"./i18n-C7VVFIdN.js";import"./badge-BvMdmUqJ.js";import"./query-DxhDvnDC.js";import"./router-D8u_RlVh.js";import"./radix-CmyU-WBH.js";function B(){const{t:s}=x(),t=u.useMemo(()=>{const i=s("help.sections.configuration.items",{returnObjects:!0}),n=s("help.sections.claudeCodeConfig.items",{returnObjects:!0}),c=s("help.sections.codexConfig.items",{returnObjects:!0}),d=s("help.sections.usage.items",{returnObjects:!0}),g=s("help.sections.tips.items",{returnObjects:!0});return[{title:s("help.sections.configuration.title"),items:i},{title:s("help.sections.claudeCodeConfig.title"),items:n},{title:s("help.sections.codexConfig.title"),items:c},{title:s("help.sections.usage.title"),items:d},{title:s("help.sections.tips.title"),items:g}]},[s]),r=s("help.faq.items",{returnObjects:!0}),l=u.useMemo(()=>[{id:"configuration",title:t[0].title,subtitle:t[0].items[0]??""},{id:"claude",title:t[1].title,subtitle:t[1].items[0]??""},{id:"codex",title:t[2].title,subtitle:t[2].items[0]??""},{id:"faq",title:s("help.faq.title"),subtitle:`${r.length} FAQ`}],[r.length,t,s]);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(w,{icon:e.jsx(b,{className:"h-5 w-5","aria-hidden":"true"}),title:s("help.title"),description:s("help.intro"),eyebrow:"Guided Setup",breadcrumb:"Gateway / Help",helper:s("help.helper"),badge:`${t.length} guides`}),e.jsx(p,{children:e.jsxs(j,{className:"flex items-start gap-4 pt-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-accent text-primary",children:e.jsx(N,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.note")})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:l.map(i=>e.jsxs("a",{href:`#help-${i.id}`,className:"rounded-lg border border-border bg-card px-4 py-4 transition hover:bg-accent/50",children:[e.jsx("p",{className:"text-sm font-semibold",children:i.title}),e.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-muted-foreground",children:i.subtitle})]},i.id))}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{id:"help-configuration",children:e.jsx(a,{eyebrow:"01",title:t[0].title,children:e.jsx(o,{items:t[0].items})})}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold",children:s("help.clientConfig.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.clientConfig.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsxs(a,{eyebrow:"02",title:t[1].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-secondary p-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-primary-foreground",children:e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Claude Code"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"IDE / Desktop workflow"})]})]}),e.jsx(o,{items:t[1].items})]})}),e.jsx("div",{id:"help-codex",children:e.jsxs(a,{eyebrow:"03",title:t[2].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-border bg-secondary p-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-600 text-white",children:e.jsx(y,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"Codex CLI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Terminal workflow"})]})]}),e.jsx(o,{items:t[2].items})]})})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"mb-6 space-y-1 text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("help.advancedGuide.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.advancedGuide.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(a,{eyebrow:"04",title:t[3].title,children:e.jsx(o,{items:t[3].items})}),e.jsx(a,{eyebrow:"05",title:t[4].title,children:e.jsx(o,{items:t[4].items})})]})]})]}),e.jsx("div",{id:"help-faq",children:e.jsx(a,{eyebrow:"FAQ",title:s("help.faq.title"),children:e.jsx(q,{items:r})})})]})}function o({items:s}){return e.jsx("ol",{className:"flex flex-col gap-3",children:s.map((t,r)=>e.jsxs("li",{className:"flex gap-3 rounded-lg border border-border bg-card p-3",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-xl bg-primary text-xs font-medium text-primary-foreground",children:r+1}),e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:e.jsx(C,{content:t})})]},`${r}-${t}`))})}function C({content:s}){const{t}=x();if(s.includes("```")){const r=s.split("```");return e.jsx("div",{className:"space-y-2",children:r.map((l,i)=>{if(i%2===0)return l?e.jsx("div",{className:"whitespace-pre-line",children:m(l)},i):null;{const[n,...c]=l.split(`
|
|
2
2
|
`),d=c.join(`
|
|
3
3
|
`);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n||"bash"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>h(d),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-lg border border-border bg-secondary p-3 text-xs",children:e.jsx("code",{children:d})})]},i)}})})}return s.includes(`
|
|
4
4
|
`)?e.jsx("div",{className:"whitespace-pre-line",children:m(s)}):e.jsx("div",{children:m(s)})}function m(s){return s.split(/(\*\*[^*]+\*\*)/g).map((r,l)=>r.startsWith("**")&&r.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:r.slice(2,-2)},l):e.jsx("span",{children:r},l))}function q({items:s}){return s.length===0?null:e.jsx("dl",{className:"flex flex-col gap-3",children:s.map(t=>e.jsx(p,{children:e.jsxs(j,{className:"pt-4",children:[e.jsx("dt",{className:"text-sm font-medium",children:t.q}),e.jsx("dd",{className:"mt-2 text-sm text-muted-foreground",children:e.jsx(k,{content:t.a})})]})},t.q))})}function k({content:s}){const{t}=x();if(s.includes("1)")||s.includes("2)")){const r=s.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as e,ao as S,aG as E}from"./vendor-
|
|
1
|
+
import{r as n,j as e,ao as S,aG as E}from"./vendor-5iCEqDpV.js";import{i as k,L as F,B as L}from"./index-BzuBtvAC.js";import{C as j,a as b,b as G,c as P,d as T,e as A}from"./card-CjhYPqKk.js";import{I as N}from"./input-BnFZKjRM.js";import{L as y}from"./label-i5-Lf72z.js";import{u as B}from"./i18n-C7VVFIdN.js";import{c as D,u as I}from"./router-D8u_RlVh.js";import"./query-DxhDvnDC.js";import"./radix-CmyU-WBH.js";function O(){const{t:s}=B(),a=D(),l=I(),{authEnabled:o,isAuthenticated:u,loading:d,login:w,error:x}=k(),[i,p]=n.useState({username:"",password:""}),[h,m]=n.useState(null),[f,g]=n.useState(!1),c=n.useMemo(()=>{var t;const r=l.state;return((t=r==null?void 0:r.from)==null?void 0:t.pathname)??"/"},[l.state]);n.useEffect(()=>{if(!o&&!d){a(c,{replace:!0});return}o&&u&&!d&&a(c,{replace:!0})},[o,c,u,d,a]);const C=async r=>{if(r.preventDefault(),m(null),!i.username.trim()||!i.password){m(s("login.validation.required"));return}g(!0);try{await w(i.username.trim(),i.password),a(c,{replace:!0})}catch(t){m(t instanceof Error?t.message:s("login.validation.failed"))}finally{g(!1)}};return d?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsx(j,{className:"w-full max-w-md",children:e.jsx(b,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(F,{})})})}):o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4 py-10",children:e.jsxs("div",{className:"mx-auto grid w-full max-w-5xl items-center gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(400px,0.8fr)]",children:[e.jsx("div",{className:"hidden lg:block",children:e.jsxs("div",{className:"max-w-lg space-y-6",children:[e.jsx("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-primary/20 bg-accent px-3 py-1 text-xs font-semibold text-primary",children:"Secure Gateway Control"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-foreground",children:s("login.title")}),e.jsx("p",{className:"max-w-md text-base leading-7 text-muted-foreground",children:s("login.description")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(v,{icon:e.jsx(S,{className:"h-5 w-5","aria-hidden":"true"}),title:s("login.hint"),description:s("about.support.tip")}),e.jsx(v,{icon:e.jsx(E,{className:"h-5 w-5","aria-hidden":"true"}),title:"Session protected",description:s("help.note")})]})]})}),e.jsxs(j,{className:"w-full",children:[e.jsxs(G,{className:"pb-4 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground",children:"GW"}),e.jsx(P,{className:"text-xl",children:s("login.title")}),e.jsx(T,{children:s("login.description")})]}),e.jsx(b,{children:e.jsxs("form",{className:"space-y-4",onSubmit:C,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(N,{id:"username",value:i.username,autoComplete:"username",autoFocus:!0,onChange:r=>p(t=>({...t,username:r.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(N,{id:"password",type:"password",value:i.password,autoComplete:"current-password",onChange:r=>p(t=>({...t,password:r.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),h||x?e.jsx("div",{className:"rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:h||x}):null,e.jsx(L,{type:"submit",className:"w-full",disabled:f,children:s(f?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(A,{className:"justify-center pt-2",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})]})}):null}function v({description:s,icon:a,title:l}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:a}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-foreground",children:l}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s})]})}export{O as default};
|