@chenpu17/cc-gw 0.8.0-alpha.2 → 0.8.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +5 -5
- package/src/web/dist/assets/{About-CiTmsH3_.js → About-BWDRyUez.js} +1 -1
- package/src/web/dist/assets/{ApiKeys-6rCCLhIC.js → ApiKeys-DkOlFxcs.js} +1 -1
- package/src/web/dist/assets/{ConfirmDialog-A9gywPpz.js → ConfirmDialog-DFy4NI8g.js} +1 -1
- package/src/web/dist/assets/{Dashboard-BoZHGcx0.js → Dashboard-Csl3HA0l.js} +1 -1
- package/src/web/dist/assets/{Events-DAiVr1Fh.js → Events-BKTkKtKe.js} +1 -1
- package/src/web/dist/assets/{Help-5dtFavzf.js → Help-BcryNGLt.js} +1 -1
- package/src/web/dist/assets/{Login-Bf2fjws1.js → Login-Bi-LLRbT.js} +1 -1
- package/src/web/dist/assets/{Logs-63hL3C0b.js → Logs-BcNmJUBA.js} +1 -1
- package/src/web/dist/assets/{ModelManagement-Sh2TbDu3.js → ModelManagement-BL2IOQpn.js} +1 -1
- package/src/web/dist/assets/{PageHeader-BfplRrls.js → PageHeader-Da1cmUY0.js} +1 -1
- package/src/web/dist/assets/{PageSection-DLrvM7lY.js → PageSection-Bf8b2jG0.js} +1 -1
- package/src/web/dist/assets/{Settings-I4pHQi8Z.js → Settings-BVKO0J1z.js} +1 -1
- package/src/web/dist/assets/{Skeleton-m_JcEeRW.js → Skeleton-CN-bCufq.js} +1 -1
- package/src/web/dist/assets/{card-pQJ3gJlC.js → card-BD2y3CjZ.js} +1 -1
- package/src/web/dist/assets/{index-CB0xlluu.js → index-BuTkie0t.js} +2 -2
- package/src/web/dist/assets/{input-DmlfmLRF.js → input-BHq9dQGf.js} +1 -1
- package/src/web/dist/assets/{label-WnrqWaUM.js → label-CUv6yhdE.js} +1 -1
- package/src/web/dist/assets/{popover-BGLA6gjb.js → popover-0Ho_T06s.js} +1 -1
- package/src/web/dist/assets/{select-f3RCxJ98.js → select-Dq7kCMCk.js} +1 -1
- package/src/web/dist/assets/{switch-BSgZEVkb.js → switch-NOIFebYg.js} +1 -1
- package/src/web/dist/assets/{useApiQuery-BGQDgPyp.js → useApiQuery-BkAH5SvI.js} +1 -1
- package/src/web/dist/index.html +1 -1
package/README.md
CHANGED
|
@@ -118,8 +118,8 @@ Linux 版本使用 `musl`,Windows 版本使用静态 CRT,目标是让用户
|
|
|
118
118
|
```bash
|
|
119
119
|
pnpm pack:dry-run
|
|
120
120
|
pnpm --dir packages/native/darwin-arm64 pack --pack-destination ../../../.pack/native
|
|
121
|
-
npm install -g ./.pack/native/chenpu17-cc-gw-darwin-arm64-0.8.0-alpha.
|
|
122
|
-
npm install -g ./.pack/chenpu17-cc-gw-0.8.0-alpha.
|
|
121
|
+
npm install -g ./.pack/native/chenpu17-cc-gw-darwin-arm64-0.8.0-alpha.3.tgz
|
|
122
|
+
npm install -g ./.pack/chenpu17-cc-gw-0.8.0-alpha.3.tgz
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
当前发布目标:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenpu17/cc-gw",
|
|
3
|
-
"version": "0.8.0-alpha.
|
|
3
|
+
"version": "0.8.0-alpha.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Rust-backed local Claude Code compatible gateway with web console and CLI daemon.",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"optionalDependencies": {
|
|
28
|
-
"@chenpu17/cc-gw-darwin-arm64": "0.8.0-alpha.
|
|
29
|
-
"@chenpu17/cc-gw-linux-arm64": "0.8.0-alpha.
|
|
30
|
-
"@chenpu17/cc-gw-
|
|
31
|
-
"@chenpu17/cc-gw-
|
|
28
|
+
"@chenpu17/cc-gw-darwin-arm64": "0.8.0-alpha.3",
|
|
29
|
+
"@chenpu17/cc-gw-linux-arm64": "0.8.0-alpha.3",
|
|
30
|
+
"@chenpu17/cc-gw-win32-x64": "0.8.0-alpha.3",
|
|
31
|
+
"@chenpu17/cc-gw-linux-x64": "0.8.0-alpha.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"colorette": "^2.0.20",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,f as e,ar as w,as as k,ad as E,a3 as I}from"./vendor-C92xTG6Z.js";import{u as L}from"./useApiQuery-
|
|
1
|
+
import{r as i,f as e,ar as w,as as k,ad as E,a3 as I}from"./vendor-C92xTG6Z.js";import{u as L}from"./useApiQuery-BkAH5SvI.js";import{u as C,B as j}from"./index-BuTkie0t.js";import{P as S,B as o}from"./PageHeader-Da1cmUY0.js";import{P as d}from"./PageSection-Bf8b2jG0.js";import{C as N,a as y}from"./card-BD2y3CjZ.js";import{u as B}from"./i18n-CZ1qKIdj.js";import"./query-CDpWKdnY.js";import"./router-DjNibHfR.js";import"./radix-Ccu1urVd.js";const P="0.8.0-alpha.3",V={version:P},M={VITE_BUILD_TIME:"2026-03-14T13:58:08.806Z"};function v({items:a}){return a.length===0?null:e.jsx("dl",{className:"grid gap-4 sm:grid-cols-2",children:a.map(s=>e.jsx(N,{className:"surface-1",children:e.jsxs(y,{className:"pt-4",children:[e.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s.label}),e.jsx("dd",{className:"mt-1 text-sm font-semibold",children:s.value}),s.hint&&e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.hint})]})},s.label))})}function H(){var m,p,b,x,h,f,g;const{t:a}=B(),{pushToast:s}=C(),t=L(["status","gateway"],{url:"/api/status",method:"GET"},{staleTime:6e4});i.useEffect(()=>{t.isError&&t.error&&s({title:a("about.toast.statusError.title"),description:t.error.message,variant:"error"})},[t.isError,t.error,s,a]);const l=V.version,c=i.useMemo(()=>({buildTime:M.VITE_BUILD_TIME}),[]),T=i.useMemo(()=>{var r,n;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",{className:"font-mono text-primary",children:["v",l]})},{label:a("about.app.labels.buildTime"),value:c.buildTime,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",{className:"font-mono",children:((n=t.data)==null?void 0:n.backendVersion)??"-"})}]},[l,c.buildTime,(m=t.data)==null?void 0:m.backendVersion,(p=t.data)==null?void 0:p.runtime,a]),u=i.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: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:((r=t.data.pid)==null?void 0:r.toLocaleString())??"-"}]:[]},[t.data,a]),_=()=>{s({title:a("about.toast.updatesPlanned"),variant:"info"})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(S,{icon:e.jsx(k,{className:"h-5 w-5","aria-hidden":"true"}),title:a("about.title"),description:a("about.description"),badge:`v${l}`,actions:e.jsxs(j,{onClick:_,children:[e.jsx(w,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("about.support.actions.checkUpdates")]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(o,{variant:"outline",children:((b=t.data)==null?void 0:b.runtime)??"rust"}),e.jsx(o,{variant:"outline",children:((x=t.data)==null?void 0:x.platform)??"-"}),e.jsxs(o,{variant:"secondary",children:[a("about.status.labels.providers"),": ",((f=(h=t.data)==null?void 0:h.providers)==null?void 0:f.toLocaleString())??"-"]}),e.jsxs(o,{variant:"secondary",children:[a("about.status.labels.active"),": ",(((g=t.data)==null?void 0:g.activeRequests)??0).toLocaleString()]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(d,{title:a("about.app.title"),description:a("about.app.subtitle"),children:e.jsx(v,{items:T})}),e.jsx(d,{title:a("about.status.title"),description:a("about.status.subtitle"),actions:e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>t.refetch(),disabled:t.isFetching,children:[e.jsx(E,{className:`mr-2 h-4 w-4 ${t.isFetching?"animate-spin":""}`,"aria-hidden":"true"}),t.isFetching?a("common.actions.refreshing"):a("common.actions.refresh")]}),children:t.isLoading?e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-2 text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-primary border-t-transparent"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("about.status.loading")})]}):u.length>0?e.jsx(v,{items:u}):e.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-1 rounded-[1.25rem] border border-dashed border-border/70 bg-background/45 p-6 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:a("about.status.empty")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("common.actions.refresh")})]})})]}),e.jsx(d,{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(N,{className:"surface-1",children:e.jsxs(y,{className:"flex flex-col gap-4 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-2xl bg-primary/10 text-primary shadow-[inset_0_0_0_1px_rgba(59,130,246,0.08)]",children:e.jsx(I,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"flex-1 text-sm text-muted-foreground",children:a("about.support.tip")})]}),e.jsx("code",{className:"inline-flex self-start rounded-xl border border-border/70 bg-background/70 px-3 py-1.5 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}export{H as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,f as e,aj as Oe,a1 as de,al as pe,am as me,an as ue,ao as We,ap as Fe,O as Pe}from"./vendor-C92xTG6Z.js";import{E as Ie}from"./EChart-C_zeFtIj.js";import{u as P}from"./useApiQuery-BGQDgPyp.js";import{c as V,u as Re,h as Me,B as c,a as K,t as C}from"./index-CB0xlluu.js";import{P as ze,B as y}from"./PageHeader-BfplRrls.js";import{P as I}from"./PageSection-DLrvM7lY.js";import{D as R,a as M,b as z,c as $,d as xe,e as U,C as $e}from"./ConfirmDialog-A9gywPpz.js";import{c as Ue}from"./clipboard-CALi6bTW.js";import{I as he}from"./input-DmlfmLRF.js";import{L as G}from"./label-WnrqWaUM.js";import{C as J,a as X}from"./card-pQJ3gJlC.js";import{u as Y}from"./i18n-CZ1qKIdj.js";import{e as Ge}from"./charts-core-BE9sa9zn.js";import"./charts-react-Dnkr-ZWt.js";import"./query-CDpWKdnY.js";import"./router-DjNibHfR.js";import"./radix-Ccu1urVd.js";import"./charts-engine-DAwKT7Yg.js";const be=r.forwardRef(({className:a,...i},l)=>e.jsx("textarea",{className:V("flex min-h-[96px] w-full rounded-[1.35rem] border border-border/80 bg-background/85 px-4 py-3 text-base shadow-[0_1px_2px_rgba(15,23,42,0.03)] ring-offset-background placeholder:text-muted-foreground/90 transition-all duration-200 focus-visible:border-primary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:l,...i}));be.displayName="Textarea";function He(){const[a,i]=r.useState([]);return r.useEffect(()=>{const l=[{id:"anthropic",label:"Anthropic"},{id:"openai",label:"OpenAI"}];K.get("/api/custom-endpoints").then(m=>{const x=(m.data.endpoints??[]).map(d=>({id:d.id,label:d.label}));i([...l,...x])}).catch(()=>{i(l)})},[]),a}function ye({available:a,selected:i,onChange:l,hint:m}){const{t:x}=Y(),d=i.length===0,E=()=>{l([])},N=o=>{i.includes(o)?l(i.filter(w=>w!==o)):l([...i,o])};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:m}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-2xl border border-border/70 bg-background/70 px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-primary/5",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:E,className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm font-medium",children:x("apiKeys.allEndpoints")})]}),e.jsx("div",{className:"grid max-h-40 gap-1 overflow-y-auto",children:a.map(o=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-2xl border border-border/70 bg-background/70 px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-primary/5",children:[e.jsx("input",{type:"checkbox",checked:!d&&i.includes(o.id),onChange:()=>N(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 H({icon:a,title:i,description:l}){return e.jsxs("div",{className:"rounded-[1.25rem] border border-white/50 bg-card/88 p-4 shadow-[0_1px_2px_rgba(15,23,42,0.03)]",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-2xl bg-primary/10 text-primary shadow-[inset_0_0_0_1px_rgba(59,130,246,0.08)]",children:a}),e.jsx("p",{className:"mt-4 text-sm font-semibold",children:i}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:l})]})}const Qe=[{value:1,labelKey:"apiKeys.analytics.range.today"},{value:7,labelKey:"apiKeys.analytics.range.week"},{value:30,labelKey:"apiKeys.analytics.range.month"}];function ma(){const{t:a}=Y(),{pushToast:i}=Re(),[l,m]=r.useState(!1),[x,d]=r.useState(""),[E,N]=r.useState(""),[o,w]=r.useState([]),[p,L]=r.useState(null),[S,Z]=r.useState(null),[u,A]=r.useState(null),[b,fe]=r.useState(7),[ee,ae]=r.useState(new Map),[je,se]=r.useState(null),[f,D]=r.useState(null),[q,te]=r.useState([]),[O,ve]=r.useState(""),[_,Ke]=r.useState("all"),ie=He(),j=P(["api-keys"],{url:"/api/keys",method:"GET"}),T=P(["api-keys","overview",b],{url:"/api/stats/api-keys/overview",method:"GET",params:{days:b}}),k=P(["api-keys","usage",b],{url:"/api/stats/api-keys/usage",method:"GET",params:{days:b,limit:10}}),g=j.data??[],v=T.data,h=k.data??[],Ne=g.some(s=>s.isWildcard),re=g.filter(s=>{var t;return!s.isWildcard&&(((t=s.allowedEndpoints)==null?void 0:t.length)??0)>0}).length,we=v?v.totalKeys.toLocaleString():"-",ke=v?v.enabledKeys.toLocaleString():"-",Ce=v?v.activeKeys.toLocaleString():"-",W=r.useMemo(()=>g.filter(s=>{if(!(_==="all"||(_==="enabled"?s.enabled:!s.enabled)))return!1;const n=O.trim().toLowerCase();return n?[s.name,s.description??"",s.maskedKey??"",...s.allowedEndpoints??[]].join(" ").toLowerCase().includes(n):!0}),[g,O,_]),ne=async()=>{if(!x.trim()){i({title:a("apiKeys.errors.nameRequired"),variant:"error"});return}try{const s=await K.post("/api/keys",{name:x.trim(),description:E.trim()||void 0,allowedEndpoints:o.length>0?o:void 0});L(s.data),m(!1),d(""),N(""),w([]),j.refetch(),T.refetch(),k.refetch(),i({title:a("apiKeys.toast.keyCreated"),variant:"success"})}catch(s){const t=C(s);i({title:a("apiKeys.toast.createFailure",{message:t.message}),variant:"error"})}},Ee=async(s,t)=>{try{await K.patch(`/api/keys/${s}`,{enabled:!t}),j.refetch(),T.refetch(),i({title:a("apiKeys.toast.keyUpdated"),variant:"success"})}catch(n){const F=C(n);i({title:a("apiKeys.toast.updateFailure",{message:F.message}),variant:"error"})}},Se=async()=>{if(u){Z(u.id);try{await K.delete(`/api/keys/${u.id}`),j.refetch(),T.refetch(),k.refetch(),i({title:a("apiKeys.toast.keyDeleted"),variant:"success"}),A(null)}catch(s){const t=C(s);i({title:a("apiKeys.toast.deleteFailure",{message:t.message}),variant:"error"})}finally{Z(null)}}},De=async s=>{if(!ee.has(s)){se(s);try{const t=await K.get(`/api/keys/${s}/reveal`);ae(n=>new Map(n).set(s,t.data.key))}catch(t){const n=C(t);i({title:a("apiKeys.toast.revealFailure"),description:n.message,variant:"error"})}finally{se(null)}}},_e=s=>{ae(t=>{const n=new Map(t);return n.delete(s),n})},le=async s=>{try{await Ue(s),i({title:a("apiKeys.toast.keyCopied"),variant:"success"})}catch(t){i({title:a("apiKeys.toast.copyFailure"),description:t instanceof Error?t.message:a("common.unknownError"),variant:"error"})}},Te=r.useCallback(s=>{D(s),te(s.allowedEndpoints??[])},[]),Le=async()=>{if(f)try{await K.patch(`/api/keys/${f.id}`,{allowedEndpoints:q.length>0?q:null}),D(null),j.refetch(),i({title:a("apiKeys.toast.keyUpdated"),variant:"success"})}catch(s){const t=C(s);i({title:a("apiKeys.toast.updateFailure",{message:t.message}),variant:"error"})}},oe=s=>s?new Date(s).toLocaleString():a("common.noData"),Ae=r.useMemo(()=>{const s=h.map(t=>t.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:s,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.requestsSeries"),type:"bar",data:h.map(t=>t.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[h,a]),qe=r.useMemo(()=>{const s=h.map(t=>t.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[a("apiKeys.analytics.tokens.input"),a("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:s,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:h.map(t=>t.inputTokens)},{name:a("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:h.map(t=>t.outputTokens)}]}},[h,a]);return j.isLoading?e.jsx(Me,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ze,{icon:e.jsx(de,{className:"h-5 w-5","aria-hidden":"true"}),title:a("apiKeys.title"),description:a("apiKeys.description"),eyebrow:"Access Control",breadcrumb:"Gateway / API Keys",helper:a("apiKeys.helper"),actions:e.jsxs(c,{onClick:()=>m(!0),children:[e.jsx(Oe,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("apiKeys.createNew")]})}),e.jsx(I,{eyebrow:"Recommended",title:a("apiKeys.quickStart.title"),description:a("apiKeys.quickStart.description"),contentClassName:"pt-5",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(H,{icon:e.jsx(de,{className:"h-4 w-4","aria-hidden":"true"}),title:a("apiKeys.quickStart.create.title"),description:a("apiKeys.quickStart.create.description")}),e.jsx(H,{icon:e.jsx(pe,{className:"h-4 w-4","aria-hidden":"true"}),title:a("apiKeys.quickStart.restrict.title"),description:a("apiKeys.quickStart.restrict.description")}),e.jsx(H,{icon:e.jsx(me,{className:"h-4 w-4","aria-hidden":"true"}),title:a("apiKeys.quickStart.wildcard.title"),description:a("apiKeys.quickStart.wildcard.description")})]})}),e.jsx(I,{eyebrow:"Usage",title:a("apiKeys.analytics.title"),description:a("apiKeys.analytics.description",{days:b}),actions:e.jsx("div",{className:"flex items-center gap-1 rounded-full border border-border/70 bg-background/80 p-1 shadow-[0_1px_2px_rgba(15,23,42,0.03)]",children:Qe.map(s=>{const t=b===s.value;return e.jsx("button",{type:"button",onClick:()=>fe(s.value),className:V("inline-flex h-8 items-center rounded-full px-3.5 text-xs font-medium transition-all",t?"bg-primary text-primary-foreground shadow-[0_8px_18px_-14px_rgba(59,130,246,0.7)]":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:a(s.labelKey)},s.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(Q,{label:a("apiKeys.analytics.cards.total"),value:we}),e.jsx(Q,{label:a("apiKeys.analytics.cards.enabled"),value:ke}),e.jsx(Q,{label:a("apiKeys.analytics.cards.active",{days:b}),value:Ce})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(ge,{title:a("apiKeys.analytics.charts.requests"),loading:k.isLoading,empty:h.length===0,emptyText:a("apiKeys.analytics.empty"),option:Ae}),e.jsx(ge,{title:a("apiKeys.analytics.charts.tokens"),loading:k.isLoading,empty:h.length===0,emptyText:a("apiKeys.analytics.empty"),option:qe})]})]})}),e.jsx(I,{eyebrow:"Inventory",title:a("apiKeys.list.title"),description:Ne?a("apiKeys.wildcardHint"):void 0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(y,{variant:"outline",children:`${W.length}/${g.length}`}),e.jsx(y,{variant:"outline",children:a("apiKeys.summary.wildcard",{count:g.filter(s=>s.isWildcard).length})}),e.jsx(y,{variant:"outline",children:a("apiKeys.summary.restricted",{count:re})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 rounded-2xl border border-white/40 bg-card/80 p-4 md:grid-cols-[minmax(0,1fr)_180px_auto]",children:[e.jsx(he,{value:O,onChange:s=>ve(s.target.value),placeholder:a("apiKeys.filters.searchPlaceholder")}),e.jsx("div",{className:"flex items-center gap-1 rounded-full border border-border/70 bg-background/80 p-1 shadow-[0_1px_2px_rgba(15,23,42,0.03)]",children:["all","enabled","disabled"].map(s=>e.jsx("button",{type:"button",onClick:()=>Ke(s),className:V("inline-flex h-8 items-center rounded-full px-3.5 text-xs font-medium transition-all",_===s?"bg-primary text-primary-foreground shadow-[0_8px_18px_-14px_rgba(59,130,246,0.7)]":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:a(`apiKeys.filters.${s}`)},s))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(y,{variant:"outline",children:a("apiKeys.summary.wildcard",{count:g.filter(s=>s.isWildcard).length})}),e.jsx(y,{variant:"outline",children:a("apiKeys.summary.restricted",{count:re})})]})]}),g.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a("apiKeys.list.empty")})}):W.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a("apiKeys.list.emptyFiltered")})}):e.jsx("div",{className:"grid gap-4",children:W.map(s=>{const t=(s.totalInputTokens+s.totalOutputTokens).toLocaleString(),n=ee.get(s.id),F=je===s.id;return e.jsx(J,{className:"border-white/40 bg-card/90 backdrop-blur",children:e.jsx(X,{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"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:s.name}),s.isWildcard&&e.jsx(y,{variant:"secondary",children:a("apiKeys.wildcard")}),e.jsx(y,{variant:s.enabled?"default":"outline",children:s.enabled?a("apiKeys.status.enabled"):a("apiKeys.status.disabled")}),!s.isWildcard&&s.allowedEndpoints&&s.allowedEndpoints.length>0?s.allowedEndpoints.map(ce=>e.jsx(y,{variant:"outline",className:"text-xs",children:ce},ce)):s.isWildcard?null:e.jsx(y,{variant:"secondary",className:"text-xs opacity-60",children:a("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx(B,{label:a("apiKeys.requestCount"),value:s.requestCount.toLocaleString()}),e.jsx(B,{label:a("apiKeys.totalTokens"),value:t}),e.jsx(B,{label:a("apiKeys.allowedEndpoints"),value:s.isWildcard?a("apiKeys.wildcard"):s.allowedEndpoints&&s.allowedEndpoints.length>0?s.allowedEndpoints.join(", "):a("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"rounded-xl border border-border/70 bg-background/70 px-3 py-1.5 font-mono text-sm",children:s.isWildcard?a("apiKeys.wildcard"):n??s.maskedKey??"********"}),!s.isWildcard&&e.jsx("div",{className:"flex items-center gap-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void le(n),"aria-label":a("common.actions.copy"),title:a("common.actions.copy"),children:e.jsx(ue,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>_e(s.id),"aria-label":a("apiKeys.actions.hide"),title:a("apiKeys.actions.hide"),children:e.jsx(me,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void De(s.id),disabled:F,"aria-label":a("apiKeys.actions.reveal"),title:a("apiKeys.actions.reveal"),children:e.jsx(We,{className:"h-4 w-4","aria-hidden":"true"})})})]}),s.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("apiKeys.wildcardHint")}):s.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:s.description}):null,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:a("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:oe(s.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:oe(s.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!s.isWildcard&&e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>Te(s),children:[e.jsx(pe,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),a("apiKeys.editEndpoints")]}),e.jsx(c,{variant:s.enabled?"outline":"default",size:"sm",onClick:()=>Ee(s.id,s.enabled),children:s.enabled?a("apiKeys.actions.disable"):a("apiKeys.actions.enable")}),!s.isWildcard&&e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>A(s),disabled:S===s.id,"aria-label":a("apiKeys.actions.delete"),children:e.jsx(Fe,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})},s.id)})})]})}),e.jsx(R,{open:l,onOpenChange:m,children:e.jsxs(M,{children:[e.jsxs(z,{children:[e.jsx($,{children:a("apiKeys.createNew")}),e.jsx(xe,{children:a("apiKeys.createDescription")})]}),e.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(G,{htmlFor:"keyName",children:[a("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(he,{id:"keyName",value:x,onChange:s=>d(s.target.value),placeholder:a("apiKeys.keyNamePlaceholder"),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),ne())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(G,{htmlFor:"keyDescription",children:a("apiKeys.descriptionLabel")}),e.jsx(be,{id:"keyDescription",value:E,onChange:s=>N(s.target.value),placeholder:a("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(G,{children:a("apiKeys.allowedEndpoints")}),e.jsx(ye,{available:ie,selected:o,onChange:w,hint:a("apiKeys.selectEndpoints")})]})]}),e.jsxs(U,{children:[e.jsx(c,{variant:"outline",onClick:()=>{m(!1),d(""),N(""),w([])},children:a("common.actions.cancel")}),e.jsx(c,{onClick:()=>void ne(),children:a("apiKeys.createAction")})]})]})}),e.jsx(R,{open:!!p,onOpenChange:()=>L(null),children:e.jsxs(M,{children:[e.jsx(z,{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(Pe,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx($,{children:a("apiKeys.keyCreated")})]})}),e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:a("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-[1.1rem] border border-border/70 bg-background/70 px-4 py-3 font-mono text-sm",children:p==null?void 0:p.key}),(p==null?void 0:p.description)&&e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:p.description}),e.jsxs(U,{children:[e.jsxs(c,{onClick:()=>void le((p==null?void 0:p.key)??""),children:[e.jsx(ue,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("common.actions.copy")]}),e.jsx(c,{variant:"outline",onClick:()=>L(null),children:a("common.actions.close")})]})]})}),e.jsx(R,{open:!!f,onOpenChange:s=>{s||D(null)},children:e.jsxs(M,{children:[e.jsxs(z,{children:[e.jsx($,{children:a("apiKeys.editEndpoints")}),e.jsx(xe,{children:f==null?void 0:f.name})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto",children:e.jsx(ye,{available:ie,selected:q,onChange:te,hint:a("apiKeys.selectEndpoints")})}),e.jsxs(U,{children:[e.jsx(c,{variant:"outline",onClick:()=>D(null),children:a("common.actions.cancel")}),e.jsx(c,{onClick:()=>void Le(),children:a("common.save")})]})]})}),e.jsx($e,{open:!!u,onOpenChange:s=>{!s&&S===null&&A(null)},title:a("apiKeys.deleteDialogTitle"),description:a("apiKeys.confirmDelete"),confirmLabel:u&&S===u.id?a("common.actions.loading"):a("apiKeys.actions.delete"),cancelLabel:a("common.actions.cancel"),loading:u?S===u.id:!1,onConfirm:Se,children:u?e.jsx("div",{className:"rounded-[1.1rem] border border-destructive/20 bg-destructive/5 px-3 py-2 font-mono text-xs text-foreground",children:u.name}):null})]})}function Q({label:a,value:i}){return e.jsx(J,{className:"surface-1",children:e.jsxs(X,{className:"pt-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a}),e.jsx("p",{className:"mt-2 text-2xl font-semibold",children:i})]})})}function B({label:a,value:i}){return e.jsxs("div",{className:"rounded-xl border border-border/70 bg-background/60 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:a}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:i})]})}function ge({title:a,option:i,loading:l,empty:m,emptyText:x}){const{t:d}=Y();return e.jsx(J,{className:"surface-1",children:e.jsxs(X,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:a}),l?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:d("common.loadingShort")})}):m?e.jsx("div",{className:"flex h-[280px] items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:x})}):e.jsx(Ie,{echarts:Ge,option:i,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}export{ma as default};
|
|
1
|
+
import{r,f as e,aj as Oe,a1 as de,al as pe,am as me,an as ue,ao as We,ap as Fe,O as Pe}from"./vendor-C92xTG6Z.js";import{E as Ie}from"./EChart-C_zeFtIj.js";import{u as P}from"./useApiQuery-BkAH5SvI.js";import{c as V,u as Re,h as Me,B as c,a as K,t as C}from"./index-BuTkie0t.js";import{P as ze,B as y}from"./PageHeader-Da1cmUY0.js";import{P as I}from"./PageSection-Bf8b2jG0.js";import{D as R,a as M,b as z,c as $,d as xe,e as U,C as $e}from"./ConfirmDialog-DFy4NI8g.js";import{c as Ue}from"./clipboard-CALi6bTW.js";import{I as he}from"./input-BHq9dQGf.js";import{L as G}from"./label-CUv6yhdE.js";import{C as J,a as X}from"./card-BD2y3CjZ.js";import{u as Y}from"./i18n-CZ1qKIdj.js";import{e as Ge}from"./charts-core-BE9sa9zn.js";import"./charts-react-Dnkr-ZWt.js";import"./query-CDpWKdnY.js";import"./router-DjNibHfR.js";import"./radix-Ccu1urVd.js";import"./charts-engine-DAwKT7Yg.js";const be=r.forwardRef(({className:a,...i},l)=>e.jsx("textarea",{className:V("flex min-h-[96px] w-full rounded-[1.35rem] border border-border/80 bg-background/85 px-4 py-3 text-base shadow-[0_1px_2px_rgba(15,23,42,0.03)] ring-offset-background placeholder:text-muted-foreground/90 transition-all duration-200 focus-visible:border-primary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:l,...i}));be.displayName="Textarea";function He(){const[a,i]=r.useState([]);return r.useEffect(()=>{const l=[{id:"anthropic",label:"Anthropic"},{id:"openai",label:"OpenAI"}];K.get("/api/custom-endpoints").then(m=>{const x=(m.data.endpoints??[]).map(d=>({id:d.id,label:d.label}));i([...l,...x])}).catch(()=>{i(l)})},[]),a}function ye({available:a,selected:i,onChange:l,hint:m}){const{t:x}=Y(),d=i.length===0,E=()=>{l([])},N=o=>{i.includes(o)?l(i.filter(w=>w!==o)):l([...i,o])};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:m}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-2xl border border-border/70 bg-background/70 px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-primary/5",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:E,className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm font-medium",children:x("apiKeys.allEndpoints")})]}),e.jsx("div",{className:"grid max-h-40 gap-1 overflow-y-auto",children:a.map(o=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-2xl border border-border/70 bg-background/70 px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-primary/5",children:[e.jsx("input",{type:"checkbox",checked:!d&&i.includes(o.id),onChange:()=>N(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 H({icon:a,title:i,description:l}){return e.jsxs("div",{className:"rounded-[1.25rem] border border-white/50 bg-card/88 p-4 shadow-[0_1px_2px_rgba(15,23,42,0.03)]",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-2xl bg-primary/10 text-primary shadow-[inset_0_0_0_1px_rgba(59,130,246,0.08)]",children:a}),e.jsx("p",{className:"mt-4 text-sm font-semibold",children:i}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:l})]})}const Qe=[{value:1,labelKey:"apiKeys.analytics.range.today"},{value:7,labelKey:"apiKeys.analytics.range.week"},{value:30,labelKey:"apiKeys.analytics.range.month"}];function ma(){const{t:a}=Y(),{pushToast:i}=Re(),[l,m]=r.useState(!1),[x,d]=r.useState(""),[E,N]=r.useState(""),[o,w]=r.useState([]),[p,L]=r.useState(null),[S,Z]=r.useState(null),[u,A]=r.useState(null),[b,fe]=r.useState(7),[ee,ae]=r.useState(new Map),[je,se]=r.useState(null),[f,D]=r.useState(null),[q,te]=r.useState([]),[O,ve]=r.useState(""),[_,Ke]=r.useState("all"),ie=He(),j=P(["api-keys"],{url:"/api/keys",method:"GET"}),T=P(["api-keys","overview",b],{url:"/api/stats/api-keys/overview",method:"GET",params:{days:b}}),k=P(["api-keys","usage",b],{url:"/api/stats/api-keys/usage",method:"GET",params:{days:b,limit:10}}),g=j.data??[],v=T.data,h=k.data??[],Ne=g.some(s=>s.isWildcard),re=g.filter(s=>{var t;return!s.isWildcard&&(((t=s.allowedEndpoints)==null?void 0:t.length)??0)>0}).length,we=v?v.totalKeys.toLocaleString():"-",ke=v?v.enabledKeys.toLocaleString():"-",Ce=v?v.activeKeys.toLocaleString():"-",W=r.useMemo(()=>g.filter(s=>{if(!(_==="all"||(_==="enabled"?s.enabled:!s.enabled)))return!1;const n=O.trim().toLowerCase();return n?[s.name,s.description??"",s.maskedKey??"",...s.allowedEndpoints??[]].join(" ").toLowerCase().includes(n):!0}),[g,O,_]),ne=async()=>{if(!x.trim()){i({title:a("apiKeys.errors.nameRequired"),variant:"error"});return}try{const s=await K.post("/api/keys",{name:x.trim(),description:E.trim()||void 0,allowedEndpoints:o.length>0?o:void 0});L(s.data),m(!1),d(""),N(""),w([]),j.refetch(),T.refetch(),k.refetch(),i({title:a("apiKeys.toast.keyCreated"),variant:"success"})}catch(s){const t=C(s);i({title:a("apiKeys.toast.createFailure",{message:t.message}),variant:"error"})}},Ee=async(s,t)=>{try{await K.patch(`/api/keys/${s}`,{enabled:!t}),j.refetch(),T.refetch(),i({title:a("apiKeys.toast.keyUpdated"),variant:"success"})}catch(n){const F=C(n);i({title:a("apiKeys.toast.updateFailure",{message:F.message}),variant:"error"})}},Se=async()=>{if(u){Z(u.id);try{await K.delete(`/api/keys/${u.id}`),j.refetch(),T.refetch(),k.refetch(),i({title:a("apiKeys.toast.keyDeleted"),variant:"success"}),A(null)}catch(s){const t=C(s);i({title:a("apiKeys.toast.deleteFailure",{message:t.message}),variant:"error"})}finally{Z(null)}}},De=async s=>{if(!ee.has(s)){se(s);try{const t=await K.get(`/api/keys/${s}/reveal`);ae(n=>new Map(n).set(s,t.data.key))}catch(t){const n=C(t);i({title:a("apiKeys.toast.revealFailure"),description:n.message,variant:"error"})}finally{se(null)}}},_e=s=>{ae(t=>{const n=new Map(t);return n.delete(s),n})},le=async s=>{try{await Ue(s),i({title:a("apiKeys.toast.keyCopied"),variant:"success"})}catch(t){i({title:a("apiKeys.toast.copyFailure"),description:t instanceof Error?t.message:a("common.unknownError"),variant:"error"})}},Te=r.useCallback(s=>{D(s),te(s.allowedEndpoints??[])},[]),Le=async()=>{if(f)try{await K.patch(`/api/keys/${f.id}`,{allowedEndpoints:q.length>0?q:null}),D(null),j.refetch(),i({title:a("apiKeys.toast.keyUpdated"),variant:"success"})}catch(s){const t=C(s);i({title:a("apiKeys.toast.updateFailure",{message:t.message}),variant:"error"})}},oe=s=>s?new Date(s).toLocaleString():a("common.noData"),Ae=r.useMemo(()=>{const s=h.map(t=>t.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:s,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.requestsSeries"),type:"bar",data:h.map(t=>t.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[h,a]),qe=r.useMemo(()=>{const s=h.map(t=>t.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},legend:{data:[a("apiKeys.analytics.tokens.input"),a("apiKeys.analytics.tokens.output")]},grid:{left:60,right:20,top:50,bottom:40},xAxis:{type:"category",data:s,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:h.map(t=>t.inputTokens)},{name:a("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:h.map(t=>t.outputTokens)}]}},[h,a]);return j.isLoading?e.jsx(Me,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ze,{icon:e.jsx(de,{className:"h-5 w-5","aria-hidden":"true"}),title:a("apiKeys.title"),description:a("apiKeys.description"),eyebrow:"Access Control",breadcrumb:"Gateway / API Keys",helper:a("apiKeys.helper"),actions:e.jsxs(c,{onClick:()=>m(!0),children:[e.jsx(Oe,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("apiKeys.createNew")]})}),e.jsx(I,{eyebrow:"Recommended",title:a("apiKeys.quickStart.title"),description:a("apiKeys.quickStart.description"),contentClassName:"pt-5",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(H,{icon:e.jsx(de,{className:"h-4 w-4","aria-hidden":"true"}),title:a("apiKeys.quickStart.create.title"),description:a("apiKeys.quickStart.create.description")}),e.jsx(H,{icon:e.jsx(pe,{className:"h-4 w-4","aria-hidden":"true"}),title:a("apiKeys.quickStart.restrict.title"),description:a("apiKeys.quickStart.restrict.description")}),e.jsx(H,{icon:e.jsx(me,{className:"h-4 w-4","aria-hidden":"true"}),title:a("apiKeys.quickStart.wildcard.title"),description:a("apiKeys.quickStart.wildcard.description")})]})}),e.jsx(I,{eyebrow:"Usage",title:a("apiKeys.analytics.title"),description:a("apiKeys.analytics.description",{days:b}),actions:e.jsx("div",{className:"flex items-center gap-1 rounded-full border border-border/70 bg-background/80 p-1 shadow-[0_1px_2px_rgba(15,23,42,0.03)]",children:Qe.map(s=>{const t=b===s.value;return e.jsx("button",{type:"button",onClick:()=>fe(s.value),className:V("inline-flex h-8 items-center rounded-full px-3.5 text-xs font-medium transition-all",t?"bg-primary text-primary-foreground shadow-[0_8px_18px_-14px_rgba(59,130,246,0.7)]":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:a(s.labelKey)},s.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(Q,{label:a("apiKeys.analytics.cards.total"),value:we}),e.jsx(Q,{label:a("apiKeys.analytics.cards.enabled"),value:ke}),e.jsx(Q,{label:a("apiKeys.analytics.cards.active",{days:b}),value:Ce})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(ge,{title:a("apiKeys.analytics.charts.requests"),loading:k.isLoading,empty:h.length===0,emptyText:a("apiKeys.analytics.empty"),option:Ae}),e.jsx(ge,{title:a("apiKeys.analytics.charts.tokens"),loading:k.isLoading,empty:h.length===0,emptyText:a("apiKeys.analytics.empty"),option:qe})]})]})}),e.jsx(I,{eyebrow:"Inventory",title:a("apiKeys.list.title"),description:Ne?a("apiKeys.wildcardHint"):void 0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(y,{variant:"outline",children:`${W.length}/${g.length}`}),e.jsx(y,{variant:"outline",children:a("apiKeys.summary.wildcard",{count:g.filter(s=>s.isWildcard).length})}),e.jsx(y,{variant:"outline",children:a("apiKeys.summary.restricted",{count:re})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 rounded-2xl border border-white/40 bg-card/80 p-4 md:grid-cols-[minmax(0,1fr)_180px_auto]",children:[e.jsx(he,{value:O,onChange:s=>ve(s.target.value),placeholder:a("apiKeys.filters.searchPlaceholder")}),e.jsx("div",{className:"flex items-center gap-1 rounded-full border border-border/70 bg-background/80 p-1 shadow-[0_1px_2px_rgba(15,23,42,0.03)]",children:["all","enabled","disabled"].map(s=>e.jsx("button",{type:"button",onClick:()=>Ke(s),className:V("inline-flex h-8 items-center rounded-full px-3.5 text-xs font-medium transition-all",_===s?"bg-primary text-primary-foreground shadow-[0_8px_18px_-14px_rgba(59,130,246,0.7)]":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:a(`apiKeys.filters.${s}`)},s))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(y,{variant:"outline",children:a("apiKeys.summary.wildcard",{count:g.filter(s=>s.isWildcard).length})}),e.jsx(y,{variant:"outline",children:a("apiKeys.summary.restricted",{count:re})})]})]}),g.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a("apiKeys.list.empty")})}):W.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:a("apiKeys.list.emptyFiltered")})}):e.jsx("div",{className:"grid gap-4",children:W.map(s=>{const t=(s.totalInputTokens+s.totalOutputTokens).toLocaleString(),n=ee.get(s.id),F=je===s.id;return e.jsx(J,{className:"border-white/40 bg-card/90 backdrop-blur",children:e.jsx(X,{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"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:s.name}),s.isWildcard&&e.jsx(y,{variant:"secondary",children:a("apiKeys.wildcard")}),e.jsx(y,{variant:s.enabled?"default":"outline",children:s.enabled?a("apiKeys.status.enabled"):a("apiKeys.status.disabled")}),!s.isWildcard&&s.allowedEndpoints&&s.allowedEndpoints.length>0?s.allowedEndpoints.map(ce=>e.jsx(y,{variant:"outline",className:"text-xs",children:ce},ce)):s.isWildcard?null:e.jsx(y,{variant:"secondary",className:"text-xs opacity-60",children:a("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx(B,{label:a("apiKeys.requestCount"),value:s.requestCount.toLocaleString()}),e.jsx(B,{label:a("apiKeys.totalTokens"),value:t}),e.jsx(B,{label:a("apiKeys.allowedEndpoints"),value:s.isWildcard?a("apiKeys.wildcard"):s.allowedEndpoints&&s.allowedEndpoints.length>0?s.allowedEndpoints.join(", "):a("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"rounded-xl border border-border/70 bg-background/70 px-3 py-1.5 font-mono text-sm",children:s.isWildcard?a("apiKeys.wildcard"):n??s.maskedKey??"********"}),!s.isWildcard&&e.jsx("div",{className:"flex items-center gap-1",children:n?e.jsxs(e.Fragment,{children:[e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void le(n),"aria-label":a("common.actions.copy"),title:a("common.actions.copy"),children:e.jsx(ue,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>_e(s.id),"aria-label":a("apiKeys.actions.hide"),title:a("apiKeys.actions.hide"),children:e.jsx(me,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>void De(s.id),disabled:F,"aria-label":a("apiKeys.actions.reveal"),title:a("apiKeys.actions.reveal"),children:e.jsx(We,{className:"h-4 w-4","aria-hidden":"true"})})})]}),s.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("apiKeys.wildcardHint")}):s.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:s.description}):null,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:a("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:oe(s.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:oe(s.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!s.isWildcard&&e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>Te(s),children:[e.jsx(pe,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),a("apiKeys.editEndpoints")]}),e.jsx(c,{variant:s.enabled?"outline":"default",size:"sm",onClick:()=>Ee(s.id,s.enabled),children:s.enabled?a("apiKeys.actions.disable"):a("apiKeys.actions.enable")}),!s.isWildcard&&e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>A(s),disabled:S===s.id,"aria-label":a("apiKeys.actions.delete"),children:e.jsx(Fe,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})},s.id)})})]})}),e.jsx(R,{open:l,onOpenChange:m,children:e.jsxs(M,{children:[e.jsxs(z,{children:[e.jsx($,{children:a("apiKeys.createNew")}),e.jsx(xe,{children:a("apiKeys.createDescription")})]}),e.jsxs("div",{className:"min-h-0 space-y-4 overflow-y-auto",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(G,{htmlFor:"keyName",children:[a("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(he,{id:"keyName",value:x,onChange:s=>d(s.target.value),placeholder:a("apiKeys.keyNamePlaceholder"),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),ne())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(G,{htmlFor:"keyDescription",children:a("apiKeys.descriptionLabel")}),e.jsx(be,{id:"keyDescription",value:E,onChange:s=>N(s.target.value),placeholder:a("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(G,{children:a("apiKeys.allowedEndpoints")}),e.jsx(ye,{available:ie,selected:o,onChange:w,hint:a("apiKeys.selectEndpoints")})]})]}),e.jsxs(U,{children:[e.jsx(c,{variant:"outline",onClick:()=>{m(!1),d(""),N(""),w([])},children:a("common.actions.cancel")}),e.jsx(c,{onClick:()=>void ne(),children:a("apiKeys.createAction")})]})]})}),e.jsx(R,{open:!!p,onOpenChange:()=>L(null),children:e.jsxs(M,{children:[e.jsx(z,{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(Pe,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx($,{children:a("apiKeys.keyCreated")})]})}),e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:a("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-[1.1rem] border border-border/70 bg-background/70 px-4 py-3 font-mono text-sm",children:p==null?void 0:p.key}),(p==null?void 0:p.description)&&e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:p.description}),e.jsxs(U,{children:[e.jsxs(c,{onClick:()=>void le((p==null?void 0:p.key)??""),children:[e.jsx(ue,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("common.actions.copy")]}),e.jsx(c,{variant:"outline",onClick:()=>L(null),children:a("common.actions.close")})]})]})}),e.jsx(R,{open:!!f,onOpenChange:s=>{s||D(null)},children:e.jsxs(M,{children:[e.jsxs(z,{children:[e.jsx($,{children:a("apiKeys.editEndpoints")}),e.jsx(xe,{children:f==null?void 0:f.name})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto",children:e.jsx(ye,{available:ie,selected:q,onChange:te,hint:a("apiKeys.selectEndpoints")})}),e.jsxs(U,{children:[e.jsx(c,{variant:"outline",onClick:()=>D(null),children:a("common.actions.cancel")}),e.jsx(c,{onClick:()=>void Le(),children:a("common.save")})]})]})}),e.jsx($e,{open:!!u,onOpenChange:s=>{!s&&S===null&&A(null)},title:a("apiKeys.deleteDialogTitle"),description:a("apiKeys.confirmDelete"),confirmLabel:u&&S===u.id?a("common.actions.loading"):a("apiKeys.actions.delete"),cancelLabel:a("common.actions.cancel"),loading:u?S===u.id:!1,onConfirm:Se,children:u?e.jsx("div",{className:"rounded-[1.1rem] border border-destructive/20 bg-destructive/5 px-3 py-2 font-mono text-xs text-foreground",children:u.name}):null})]})}function Q({label:a,value:i}){return e.jsx(J,{className:"surface-1",children:e.jsxs(X,{className:"pt-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a}),e.jsx("p",{className:"mt-2 text-2xl font-semibold",children:i})]})})}function B({label:a,value:i}){return e.jsxs("div",{className:"rounded-xl border border-border/70 bg-background/60 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:a}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:i})]})}function ge({title:a,option:i,loading:l,empty:m,emptyText:x}){const{t:d}=Y();return e.jsx(J,{className:"surface-1",children:e.jsxs(X,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:a}),l?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:d("common.loadingShort")})}):m?e.jsx("div",{className:"flex h-[280px] items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:x})}):e.jsx(Ie,{echarts:Ge,option:i,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}export{ma as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,f as a,a5 as w}from"./vendor-C92xTG6Z.js";import{F as k,G as C,H as c,J as R,K as m,M as x,O as f}from"./radix-Ccu1urVd.js";import{c as o,B as i}from"./index-
|
|
1
|
+
import{r,f as a,a5 as w}from"./vendor-C92xTG6Z.js";import{F as k,G as C,H as c,J as R,K as m,M as x,O as f}from"./radix-Ccu1urVd.js";import{c as o,B as i}from"./index-BuTkie0t.js";const z=k,_=C,p=r.forwardRef(({className:s,...e},t)=>a.jsx(f,{ref:t,className:o("fixed inset-0 z-50 bg-slate-950/45 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",s),...e}));p.displayName=f.displayName;const u=r.forwardRef(({className:s,children:e,...t},l)=>a.jsxs(_,{children:[a.jsx(p,{}),a.jsxs(c,{ref:l,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-[1.5rem] border border-white/60 bg-background/96 p-6 shadow-[0_24px_64px_-28px_rgba(15,23,42,0.42)] backdrop-blur 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%]",s),...t,children:[e,a.jsxs(R,{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:[a.jsx(w,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));u.displayName=c.displayName;const g=({className:s,...e})=>a.jsx("div",{className:o("flex shrink-0 flex-col space-y-1.5 text-center sm:text-left",s),...e});g.displayName="DialogHeader";const b=({className:s,...e})=>a.jsx("div",{className:o("flex shrink-0 flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...e});b.displayName="DialogFooter";const j=r.forwardRef(({className:s,...e},t)=>a.jsx(m,{ref:t,className:o("text-lg font-semibold leading-none tracking-[-0.02em]",s),...e}));j.displayName=m.displayName;const h=r.forwardRef(({className:s,...e},t)=>a.jsx(x,{ref:t,className:o("text-sm leading-6 text-muted-foreground",s),...e}));h.displayName=x.displayName;function E({open:s,onOpenChange:e,title:t,description:l,confirmLabel:N,cancelLabel:y,onConfirm:v,loading:d=!1,confirmVariant:D="destructive",children:n}){return a.jsx(z,{open:s,onOpenChange:e,children:a.jsxs(u,{className:"max-w-md",children:[a.jsxs(g,{children:[a.jsx(j,{children:t}),l?a.jsx(h,{children:l}):null]}),n?a.jsx("div",{className:"text-sm text-muted-foreground",children:n}):null,a.jsxs(b,{children:[a.jsx(i,{variant:"outline",onClick:()=>e(!1),disabled:d,children:y}),a.jsx(i,{variant:D,onClick:()=>void v(),disabled:d,children:N})]})]})})}export{E as C,z as D,u as a,g as b,j as c,h as d,b as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,f as e,Y as Q,a9 as z,aa as Te,ab as Ce}from"./vendor-C92xTG6Z.js";import{E as Se}from"./EChart-C_zeFtIj.js";import{S as ke,C as Ee,T as Ie}from"./Skeleton-m_JcEeRW.js";import{P as le,B as q}from"./PageHeader-BfplRrls.js";import{P as he}from"./PageSection-DLrvM7lY.js";import{c as k,u as Re,a as Le,t as we,B as ce}from"./index-CB0xlluu.js";import{u as R}from"./useApiQuery-BGQDgPyp.js";import{C as Y,a as K}from"./card-pQJ3gJlC.js";import{S as qe,a as Me,b as Ae,c as Be,d as F}from"./select-f3RCxJ98.js";import{u as V}from"./i18n-CZ1qKIdj.js";import{e as _e}from"./charts-core-BE9sa9zn.js";import"./charts-react-Dnkr-ZWt.js";import"./router-DjNibHfR.js";import"./radix-Ccu1urVd.js";import"./query-CDpWKdnY.js";import"./charts-engine-DAwKT7Yg.js";const J=d.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:"relative w-full overflow-auto rounded-[1.25rem] border border-border/60 bg-background/45",children:e.jsx("table",{ref:s,className:k("w-full caption-bottom border-collapse text-sm",t),...a})}));J.displayName="Table";const W=d.forwardRef(({className:t,...a},s)=>e.jsx("thead",{ref:s,className:k("bg-muted/35 [&_tr]:border-b [&_tr]:border-border/60",t),...a}));W.displayName="TableHeader";const X=d.forwardRef(({className:t,...a},s)=>e.jsx("tbody",{ref:s,className:k("[&_tr:last-child]:border-0",t),...a}));X.displayName="TableBody";const Pe=d.forwardRef(({className:t,...a},s)=>e.jsx("tfoot",{ref:s,className:k("border-t bg-muted/45 font-medium [&>tr]:last:border-b-0",t),...a}));Pe.displayName="TableFooter";const D=d.forwardRef(({className:t,...a},s)=>e.jsx("tr",{ref:s,className:k("border-b border-border/50 transition-all duration-150","hover:bg-primary/5 data-[state=selected]:bg-primary/10","group",t),...a}));D.displayName="TableRow";const p=d.forwardRef(({className:t,...a},s)=>e.jsx("th",{ref:s,className:k("h-12 px-4 text-left align-middle text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/80","[&:has([role=checkbox])]:pr-0",t),...a}));p.displayName="TableHead";const b=d.forwardRef(({className:t,...a},s)=>e.jsx("td",{ref:s,className:k("px-4 py-3.5 align-middle text-sm","[&:has([role=checkbox])]:pr-0","group-hover:text-foreground transition-colors",t),...a}));b.displayName="TableCell";const De=d.forwardRef(({className:t,...a},s)=>e.jsx("caption",{ref:s,className:k("mt-4 text-sm text-muted-foreground",t),...a}));De.displayName="TableCaption";const H=15e3,U=6e4;function P(t,a,s){return t==null?"-":`${t.toLocaleString(void 0,s)} ${a}`}function me(t){if(t==null)return"-";if(t<1024)return`${t} B`;const a=["KB","MB","GB","TB"];let s=t/1024,h=0;for(;s>=1024&&h<a.length-1;)s/=1024,h+=1;return`${s.toFixed(s>=100?0:s>=10?1:2)} ${a[h]}`}const S={requests:"#3b82f6",input:"#10b981",output:"#f59e0b",cacheRead:"#8b5cf6",cacheCreation:"#f43f5e"};function rt(){var se,ae,re,oe,ne,de;const{t}=V(),{pushToast:a}=Re(),[s,h]=d.useState("all"),[l,o]=d.useState(!1),u=s==="all"?void 0:s,M=R(["custom-endpoints"],{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:U,refetchIntervalInBackground:!0}),y=R(["stats","overview",s],{url:"/api/stats/overview",method:"GET",params:u?{endpoint:u}:void 0},{refetchInterval:H,refetchIntervalInBackground:!0}),v=R(["stats","daily",14,s],{url:"/api/stats/daily",method:"GET",params:{days:14,...u?{endpoint:u}:{}}},{refetchInterval:U,refetchIntervalInBackground:!0}),x=R(["stats","model",7,6,s],{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...u?{endpoint:u}:{}}},{refetchInterval:U,refetchIntervalInBackground:!0}),N=R(["status",s],{url:"/api/status",method:"GET",params:u?{endpoint:u}:void 0},{refetchInterval:H,refetchIntervalInBackground:!0}),g=R(["db","info"],{url:"/api/db/info",method:"GET"},{refetchInterval:H,refetchIntervalInBackground:!0}),Z=g.refetch??(async()=>{}),T=R(["logs","recent",s],{url:"/api/logs",method:"GET",params:{limit:5,...u?{endpoint:u}:{}}},{refetchInterval:H,refetchIntervalInBackground:!0}),ue=d.useCallback(async()=>{await Promise.all([M.refetch(),y.refetch(),v.refetch(),x.refetch(),N.refetch(),g.refetch(),T.refetch()])},[M,v,g,T,x,y,N]),ee=M.isFetching||y.isFetching||v.isFetching||x.isFetching||N.isFetching||g.isFetching||T.isFetching;d.useEffect(()=>{y.isError&&y.error&&a({title:t("dashboard.toast.overviewError"),description:y.error.message,variant:"error"})},[y.isError,y.error,a,t]),d.useEffect(()=>{v.isError&&v.error&&a({title:t("dashboard.toast.dailyError"),description:v.error.message,variant:"error"})},[v.isError,v.error,a,t]),d.useEffect(()=>{x.isError&&x.error&&a({title:t("dashboard.toast.modelError"),description:x.error.message,variant:"error"})},[x.isError,x.error,a,t]),d.useEffect(()=>{N.isError&&N.error&&a({title:t("dashboard.toast.statusError"),description:N.error.message,variant:"error"})},[N.isError,N.error,a,t]),d.useEffect(()=>{g.isError&&g.error&&a({title:t("dashboard.toast.dbError"),description:g.error.message,variant:"error"})},[g.isError,g.error,a,t]);const xe=d.useCallback(async()=>{if(!l){o(!0);try{await Le.post("/api/db/compact"),await Z(),a({title:t("dashboard.toast.compactSuccess.title"),description:t("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(r){const n=we(r);a({title:t("dashboard.toast.compactError.title"),description:n.message,variant:"error"})}finally{o(!1)}}},[l,a,Z,t]);d.useEffect(()=>{T.isError&&T.error&&a({title:t("dashboard.toast.recentError"),description:T.error.message,variant:"error"})},[T.isError,T.error,a,t]);const i=y.data,C=v.data??[],c=x.data??[],E=N.data,L=g.data,pe=((se=T.data)==null?void 0:se.items)??[],be=L?me(L.totalBytes??L.sizeBytes):"-",ge=me(L==null?void 0:L.memoryRssBytes),te=s==="all"?t("dashboard.filters.endpointAll"):s==="anthropic"?t("dashboard.filters.endpointAnthropic"):s==="openai"?t("dashboard.filters.endpointOpenAI"):((oe=(re=(ae=M.data)==null?void 0:ae.endpoints)==null?void 0:re.find(r=>r.id===s))==null?void 0:oe.label)||s,fe=C.reduce((r,n)=>r+n.requestCount,0),$=C.reduce((r,n)=>!r||n.requestCount>r.requestCount?n:r,null),A=c[0],B=c.filter(r=>r.avgTtftMs!=null&&r.avgTtftMs>0).sort((r,n)=>(r.avgTtftMs??Number.POSITIVE_INFINITY)-(n.avgTtftMs??Number.POSITIVE_INFINITY))[0],je=d.useMemo(()=>{const r=C.map(j=>j.date),n=t("dashboard.charts.barRequests"),m=t("dashboard.charts.lineInput"),_=t("dashboard.charts.lineOutput"),f=t("dashboard.charts.lineCacheRead"),ie=t("dashboard.charts.lineCacheCreation");return{tooltip:{trigger:"axis"},legend:{data:[n,m,_,f,ie]},grid:{left:60,right:40,top:60,bottom:60},xAxis:{type:"category",data:r},yAxis:{type:"value"},series:[{name:n,type:"bar",data:C.map(j=>j.requestCount),itemStyle:{color:S.requests,borderRadius:[4,4,0,0]}},{name:m,type:"line",data:C.map(j=>j.inputTokens),smooth:!0,itemStyle:{color:S.input},lineStyle:{width:2}},{name:_,type:"line",data:C.map(j=>j.outputTokens),smooth:!0,itemStyle:{color:S.output},lineStyle:{width:2}},{name:f,type:"line",data:C.map(j=>j.cacheReadTokens),smooth:!0,itemStyle:{color:S.cacheRead},lineStyle:{width:2}},{name:ie,type:"line",data:C.map(j=>j.cacheCreationTokens),smooth:!0,itemStyle:{color:S.cacheCreation},lineStyle:{width:2}}]}},[C,t]),ye=d.useMemo(()=>{const r=c.map(f=>`${f.provider}/${f.model}`),n=t("dashboard.charts.barRequests"),m=t("dashboard.charts.lineInput"),_=t("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis"},legend:{data:[n,m,_]},grid:{left:80,right:60,top:60,bottom:100},xAxis:{type:"category",data:r,axisLabel:{rotate:30}},yAxis:[{type:"value",name:n},{type:"value",name:t("dashboard.charts.axisTokens"),position:"right"}],series:[{name:n,type:"bar",data:c.map(f=>f.requests),itemStyle:{color:S.requests,borderRadius:[4,4,0,0]}},{name:m,type:"line",yAxisIndex:1,smooth:!0,data:c.map(f=>f.inputTokens??0),itemStyle:{color:S.input}},{name:_,type:"line",yAxisIndex:1,smooth:!0,data:c.map(f=>f.outputTokens??0),itemStyle:{color:S.output}}]}},[c,t]),ve=d.useMemo(()=>{const r=c.map(m=>`${m.provider}/${m.model}`),n=t("dashboard.charts.ttftLabel");return{tooltip:{trigger:"axis"},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:r,axisLabel:{rotate:30}},yAxis:{type:"value",name:t("dashboard.charts.ttftAxis")},series:[{name:n,type:"bar",data:c.map(m=>m.avgTtftMs??0),itemStyle:{color:S.requests,borderRadius:[4,4,0,0]}}]}},[c,t]),Ne=d.useMemo(()=>{const r=c.map(m=>`${m.provider}/${m.model}`),n=t("dashboard.charts.tpotLabel");return{tooltip:{trigger:"axis"},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:r,axisLabel:{rotate:30}},yAxis:{type:"value",name:t("dashboard.charts.tpotAxis")},series:[{name:n,type:"bar",data:c.map(m=>m.avgTpotMs??0),itemStyle:{color:S.output,borderRadius:[4,4,0,0]}}]}},[c,t]);return y.isPending||N.isPending||g.isPending?e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(le,{icon:e.jsx(Q,{className:"h-5 w-5","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description")}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:Array.from({length:6}).map((r,n)=>e.jsx(ke,{},n))}),e.jsx("div",{className:"grid gap-6 lg:grid-cols-2",children:Array.from({length:4}).map((r,n)=>e.jsx(Ee,{},n))}),e.jsx("div",{className:"rounded-[1.25rem] border border-border/70 bg-background/55",children:e.jsx("table",{className:"w-full",children:e.jsx("tbody",{children:Array.from({length:5}).map((r,n)=>e.jsx(Ie,{columns:6},n))})})})]}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(le,{icon:e.jsx(Q,{className:"h-5 w-5","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description"),badge:te,actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t("dashboard.filters.endpoint")}),e.jsxs(qe,{value:s,onValueChange:h,children:[e.jsx(Me,{className:"w-[140px]",children:e.jsx(Ae,{})}),e.jsxs(Be,{children:[e.jsx(F,{value:"all",children:t("dashboard.filters.endpointAll")}),e.jsx(F,{value:"anthropic",children:t("dashboard.filters.endpointAnthropic")}),e.jsx(F,{value:"openai",children:t("dashboard.filters.endpointOpenAI")}),(de=(ne=M.data)==null?void 0:ne.endpoints)==null?void 0:de.map(r=>e.jsx(F,{value:r.id,children:r.label||r.id},r.id))]})]}),e.jsx(ce,{variant:"outline",size:"sm",onClick:()=>void ue(),disabled:ee,children:t(ee?"common.actions.refreshing":"common.actions.refresh")})]})}),E&&e.jsx(Y,{className:"surface-1",children:e.jsxs(K,{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-emerald-300/90 bg-emerald-50 px-3.5 py-2 text-sm shadow-[0_10px_24px_-20px_rgba(5,150,105,0.85)] dark:border-emerald-800 dark:bg-emerald-950/50",children:[e.jsx("span",{className:"font-semibold text-emerald-800 dark:text-emerald-200",children:t("dashboard.status.listeningLabel")}),e.jsxs("span",{className:"font-mono text-[13px] font-semibold tracking-normal text-emerald-950 dark:text-emerald-50",children:[E.host??"0.0.0.0",":",E.port]})]}),e.jsx(q,{variant:"outline",children:te})]}),e.jsx(ce,{variant:"outline",size:"sm",onClick:xe,disabled:l,children:t(l?"dashboard.actions.compacting":"dashboard.actions.compact")})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4 2xl:grid-cols-8",children:[e.jsx(I,{label:t("dashboard.labels.providers"),value:E.providers.toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.activeRequests"),value:(E.activeRequests??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.activeClientAddresses"),value:(E.activeClientAddresses??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.activeClientSessions"),value:(E.activeClientSessions??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.uniqueClientAddressesLastHour"),value:(E.uniqueClientAddressesLastHour??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.uniqueClientSessionsLastHour"),value:(E.uniqueClientSessionsLastHour??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.todayRequests"),value:((i==null?void 0:i.today.requests)??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.database"),value:be}),e.jsx(I,{label:t("dashboard.labels.memory"),value:ge})]})]})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(w,{icon:e.jsx(z,{className:"h-5 w-5"}),title:t("dashboard.cards.todayRequests"),value:(i==null?void 0:i.today.requests)??0,suffix:t("common.units.request"),color:"blue"}),e.jsx(w,{icon:e.jsx(Te,{className:"h-5 w-5"}),title:t("dashboard.cards.todayInput"),value:(i==null?void 0:i.today.inputTokens)??0,suffix:t("common.units.token"),color:"emerald"}),e.jsx(w,{icon:e.jsx(z,{className:"h-5 w-5"}),title:t("dashboard.cards.todayCacheRead"),value:(i==null?void 0:i.today.cacheReadTokens)??0,suffix:t("common.units.token"),color:"violet"}),e.jsx(w,{icon:e.jsx(z,{className:"h-5 w-5"}),title:t("dashboard.cards.todayCacheCreation"),value:(i==null?void 0:i.today.cacheCreationTokens)??0,suffix:t("common.units.token"),color:"rose"}),e.jsx(w,{icon:e.jsx(Q,{className:"h-5 w-5"}),title:t("dashboard.cards.todayOutput"),value:(i==null?void 0:i.today.outputTokens)??0,suffix:t("common.units.token"),color:"amber"}),e.jsx(w,{icon:e.jsx(Ce,{className:"h-5 w-5"}),title:t("dashboard.cards.avgLatency"),value:(i==null?void 0:i.today.avgLatencyMs)??0,suffix:t("common.units.ms"),color:"cyan"})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsx(O,{label:t("dashboard.insights.totalRequests"),value:fe.toLocaleString(),hint:t("dashboard.insights.totalRequestsHint")}),e.jsx(O,{label:t("dashboard.insights.busiestDay"),value:$?`${$.date}`:"-",hint:$?t("dashboard.insights.busiestDayHint",{value:$.requestCount.toLocaleString()}):t("common.noData")}),e.jsx(O,{label:t("dashboard.insights.topModel"),value:A?`${A.provider}/${A.model}`:"-",hint:A?t("dashboard.insights.topModelHint",{value:A.requests.toLocaleString()}):t("common.noData")}),e.jsx(O,{label:t("dashboard.insights.fastestTtft"),value:B?`${B.provider}/${B.model}`:"-",hint:B?P(B.avgTtftMs,t("common.units.ms")):t("common.noData")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(G,{title:t("dashboard.charts.requestsTitle"),description:t("dashboard.charts.requestsDesc"),loading:v.isPending,option:je,empty:!C.length,emptyText:t("dashboard.charts.empty")}),e.jsx(G,{title:t("dashboard.charts.modelTitle"),description:t("dashboard.charts.modelDesc"),loading:x.isPending,option:ye,empty:!c.length,emptyText:t("dashboard.charts.empty")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(G,{title:t("dashboard.charts.ttftTitle"),description:t("dashboard.charts.ttftDesc"),loading:x.isPending,option:ve,empty:!c.some(r=>r.avgTtftMs!=null&&r.avgTtftMs>0),emptyText:t("dashboard.charts.ttftEmpty")}),e.jsx(G,{title:t("dashboard.charts.tpotTitle"),description:t("dashboard.charts.tpotDesc"),loading:x.isPending,option:Ne,empty:!c.some(r=>r.avgTpotMs!=null&&r.avgTpotMs>0),emptyText:t("dashboard.charts.tpotEmpty")})]}),e.jsx(Fe,{models:c,loading:x.isPending}),e.jsx(He,{loading:T.isPending,records:pe})]})}const $e={blue:{gradient:"bg-gradient-to-br from-blue-500/10 via-blue-500/5 to-transparent",iconBg:"bg-blue-500/15",iconColor:"text-blue-600 dark:text-blue-400"},emerald:{gradient:"bg-gradient-to-br from-emerald-500/10 via-emerald-500/5 to-transparent",iconBg:"bg-emerald-500/15",iconColor:"text-emerald-600 dark:text-emerald-400"},amber:{gradient:"bg-gradient-to-br from-amber-500/10 via-amber-500/5 to-transparent",iconBg:"bg-amber-500/15",iconColor:"text-amber-600 dark:text-amber-400"},violet:{gradient:"bg-gradient-to-br from-violet-500/10 via-violet-500/5 to-transparent",iconBg:"bg-violet-500/15",iconColor:"text-violet-600 dark:text-violet-400"},rose:{gradient:"bg-gradient-to-br from-rose-500/10 via-rose-500/5 to-transparent",iconBg:"bg-rose-500/15",iconColor:"text-rose-600 dark:text-rose-400"},cyan:{gradient:"bg-gradient-to-br from-cyan-500/10 via-cyan-500/5 to-transparent",iconBg:"bg-cyan-500/15",iconColor:"text-cyan-600 dark:text-cyan-400"}};function w({icon:t,title:a,value:s,suffix:h,color:l="blue"}){const o=$e[l];return e.jsx(Y,{variant:"interactive",className:k("overflow-hidden",o.gradient),children:e.jsxs(K,{className:"pt-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:a}),t&&e.jsx("div",{className:k("flex h-10 w-10 items-center justify-center rounded-xl",o.iconBg,o.iconColor),children:t})]}),e.jsxs("p",{className:"text-3xl font-bold tracking-tight",children:[s.toLocaleString(),h&&e.jsx("span",{className:"ml-1.5 text-sm font-medium text-muted-foreground",children:h})]})]})})}function I({label:t,value:a}){return e.jsxs("div",{className:"rounded-2xl border border-border/70 bg-background/70 px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:t}),e.jsx("p",{className:"mt-2 text-lg font-semibold",children:a})]})}function O({label:t,value:a,hint:s}){return e.jsxs("div",{className:"rounded-[1.3rem] border border-white/50 bg-card/90 px-4 py-4 shadow-[0_1px_2px_rgba(15,23,42,0.03)] backdrop-blur",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:t}),e.jsx("p",{className:"mt-2 line-clamp-1 text-sm font-semibold",children:a}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]})}function G({title:t,description:a,option:s,loading:h,empty:l,emptyText:o}){const{t:u}=V();return e.jsx(Y,{className:"surface-1",children:e.jsxs(K,{className:"space-y-4 pt-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-semibold",children:t}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a})]}),h?e.jsx("div",{className:"flex min-h-[280px] h-[40vh] max-h-[420px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:u("common.loadingShort")})}):l?e.jsxs("div",{className:"flex min-h-[280px] h-[40vh] max-h-[420px] flex-col items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:[e.jsx(Q,{className:"mb-2 h-10 w-10 text-muted-foreground/50"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:o??u("dashboard.charts.empty")})]}):e.jsx(Se,{echarts:_e,option:s,className:"min-h-[280px] h-[40vh] max-h-[420px]",notMerge:!0,lazyUpdate:!0})]})})}function Fe({models:t,loading:a}){const{t:s}=V(),h=t.length>0;return e.jsx(he,{title:s("dashboard.modelTable.title"),description:s("dashboard.modelTable.description"),children:a?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.loadingShort")})}):h?e.jsx("div",{className:"max-h-80 overflow-auto rounded-[1.2rem]",children:e.jsxs(J,{children:[e.jsx(W,{children:e.jsxs(D,{children:[e.jsx(p,{children:s("dashboard.modelTable.columns.model")}),e.jsx(p,{className:"text-right",children:s("dashboard.modelTable.columns.requests")}),e.jsx(p,{className:"text-right",children:s("dashboard.modelTable.columns.latency")}),e.jsx(p,{className:"text-right",children:s("dashboard.modelTable.columns.ttft")}),e.jsx(p,{className:"text-right",children:s("dashboard.modelTable.columns.tpot")})]})}),e.jsx(X,{children:t.map(l=>e.jsxs(D,{children:[e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:l.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:l.model})]})}),e.jsx(b,{className:"text-right font-medium",children:l.requests.toLocaleString()}),e.jsx(b,{className:"text-right",children:P(l.avgLatencyMs,s("common.units.ms"))}),e.jsx(b,{className:"text-right",children:P(l.avgTtftMs,s("common.units.ms"))}),e.jsx(b,{className:"text-right",children:P(l.avgTpotMs,s("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${l.provider}/${l.model}`))})]})}):e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard.modelTable.empty")})})})}function He({records:t,loading:a}){const{t:s}=V(),h=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:s("dashboard.recent.title"),description:s("dashboard.recent.subtitle",{count:5}),children:a?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard.recent.loading")})}):t.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard.recent.empty")})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(q,{variant:"secondary",children:t.length}),e.jsxs(q,{variant:"outline",className:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",children:[s("common.status.success"),": ",h]}),e.jsxs(q,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[s("common.status.error"),": ",l]})]}),e.jsx("div",{className:"max-h-80 overflow-auto rounded-[1.2rem]",children:e.jsxs(J,{children:[e.jsx(W,{children:e.jsxs(D,{children:[e.jsx(p,{children:s("dashboard.recent.columns.time")}),e.jsx(p,{children:s("dashboard.recent.columns.endpoint")}),e.jsx(p,{children:s("dashboard.recent.columns.provider")}),e.jsx(p,{children:s("dashboard.recent.columns.route")}),e.jsx(p,{className:"text-right",children:s("dashboard.recent.columns.latency")}),e.jsx(p,{children:s("dashboard.recent.columns.status")})]})}),e.jsx(X,{children:t.map(o=>e.jsxs(D,{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(q,{variant:"outline",className:"text-[11px]",children:o.endpoint==="anthropic"?s("logs.table.endpointAnthropic"):o.endpoint==="openai"?s("logs.table.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??s("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"→"}),e.jsx("span",{className:"font-medium text-foreground",children:o.model})]}),o.error?e.jsx("span",{className:"truncate text-destructive",children:o.error}):null]})}),e.jsx(b,{className:"text-right font-medium",children:P(o.latency_ms,s("common.units.ms"))}),e.jsx(b,{children:e.jsx(q,{variant:o.error?"destructive":"default",className:"min-w-14 justify-center",children:(o.status_code??(o.error?500:200)).toString()})})]},o.id))})]})})]})})}export{rt as default};
|
|
1
|
+
import{r as d,f as e,Y as Q,a9 as z,aa as Te,ab as Ce}from"./vendor-C92xTG6Z.js";import{E as Se}from"./EChart-C_zeFtIj.js";import{S as ke,C as Ee,T as Ie}from"./Skeleton-CN-bCufq.js";import{P as le,B as q}from"./PageHeader-Da1cmUY0.js";import{P as he}from"./PageSection-Bf8b2jG0.js";import{c as k,u as Re,a as Le,t as we,B as ce}from"./index-BuTkie0t.js";import{u as R}from"./useApiQuery-BkAH5SvI.js";import{C as Y,a as K}from"./card-BD2y3CjZ.js";import{S as qe,a as Me,b as Ae,c as Be,d as F}from"./select-Dq7kCMCk.js";import{u as V}from"./i18n-CZ1qKIdj.js";import{e as _e}from"./charts-core-BE9sa9zn.js";import"./charts-react-Dnkr-ZWt.js";import"./router-DjNibHfR.js";import"./radix-Ccu1urVd.js";import"./query-CDpWKdnY.js";import"./charts-engine-DAwKT7Yg.js";const J=d.forwardRef(({className:t,...a},s)=>e.jsx("div",{className:"relative w-full overflow-auto rounded-[1.25rem] border border-border/60 bg-background/45",children:e.jsx("table",{ref:s,className:k("w-full caption-bottom border-collapse text-sm",t),...a})}));J.displayName="Table";const W=d.forwardRef(({className:t,...a},s)=>e.jsx("thead",{ref:s,className:k("bg-muted/35 [&_tr]:border-b [&_tr]:border-border/60",t),...a}));W.displayName="TableHeader";const X=d.forwardRef(({className:t,...a},s)=>e.jsx("tbody",{ref:s,className:k("[&_tr:last-child]:border-0",t),...a}));X.displayName="TableBody";const Pe=d.forwardRef(({className:t,...a},s)=>e.jsx("tfoot",{ref:s,className:k("border-t bg-muted/45 font-medium [&>tr]:last:border-b-0",t),...a}));Pe.displayName="TableFooter";const D=d.forwardRef(({className:t,...a},s)=>e.jsx("tr",{ref:s,className:k("border-b border-border/50 transition-all duration-150","hover:bg-primary/5 data-[state=selected]:bg-primary/10","group",t),...a}));D.displayName="TableRow";const p=d.forwardRef(({className:t,...a},s)=>e.jsx("th",{ref:s,className:k("h-12 px-4 text-left align-middle text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/80","[&:has([role=checkbox])]:pr-0",t),...a}));p.displayName="TableHead";const b=d.forwardRef(({className:t,...a},s)=>e.jsx("td",{ref:s,className:k("px-4 py-3.5 align-middle text-sm","[&:has([role=checkbox])]:pr-0","group-hover:text-foreground transition-colors",t),...a}));b.displayName="TableCell";const De=d.forwardRef(({className:t,...a},s)=>e.jsx("caption",{ref:s,className:k("mt-4 text-sm text-muted-foreground",t),...a}));De.displayName="TableCaption";const H=15e3,U=6e4;function P(t,a,s){return t==null?"-":`${t.toLocaleString(void 0,s)} ${a}`}function me(t){if(t==null)return"-";if(t<1024)return`${t} B`;const a=["KB","MB","GB","TB"];let s=t/1024,h=0;for(;s>=1024&&h<a.length-1;)s/=1024,h+=1;return`${s.toFixed(s>=100?0:s>=10?1:2)} ${a[h]}`}const S={requests:"#3b82f6",input:"#10b981",output:"#f59e0b",cacheRead:"#8b5cf6",cacheCreation:"#f43f5e"};function rt(){var se,ae,re,oe,ne,de;const{t}=V(),{pushToast:a}=Re(),[s,h]=d.useState("all"),[l,o]=d.useState(!1),u=s==="all"?void 0:s,M=R(["custom-endpoints"],{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:U,refetchIntervalInBackground:!0}),y=R(["stats","overview",s],{url:"/api/stats/overview",method:"GET",params:u?{endpoint:u}:void 0},{refetchInterval:H,refetchIntervalInBackground:!0}),v=R(["stats","daily",14,s],{url:"/api/stats/daily",method:"GET",params:{days:14,...u?{endpoint:u}:{}}},{refetchInterval:U,refetchIntervalInBackground:!0}),x=R(["stats","model",7,6,s],{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...u?{endpoint:u}:{}}},{refetchInterval:U,refetchIntervalInBackground:!0}),N=R(["status",s],{url:"/api/status",method:"GET",params:u?{endpoint:u}:void 0},{refetchInterval:H,refetchIntervalInBackground:!0}),g=R(["db","info"],{url:"/api/db/info",method:"GET"},{refetchInterval:H,refetchIntervalInBackground:!0}),Z=g.refetch??(async()=>{}),T=R(["logs","recent",s],{url:"/api/logs",method:"GET",params:{limit:5,...u?{endpoint:u}:{}}},{refetchInterval:H,refetchIntervalInBackground:!0}),ue=d.useCallback(async()=>{await Promise.all([M.refetch(),y.refetch(),v.refetch(),x.refetch(),N.refetch(),g.refetch(),T.refetch()])},[M,v,g,T,x,y,N]),ee=M.isFetching||y.isFetching||v.isFetching||x.isFetching||N.isFetching||g.isFetching||T.isFetching;d.useEffect(()=>{y.isError&&y.error&&a({title:t("dashboard.toast.overviewError"),description:y.error.message,variant:"error"})},[y.isError,y.error,a,t]),d.useEffect(()=>{v.isError&&v.error&&a({title:t("dashboard.toast.dailyError"),description:v.error.message,variant:"error"})},[v.isError,v.error,a,t]),d.useEffect(()=>{x.isError&&x.error&&a({title:t("dashboard.toast.modelError"),description:x.error.message,variant:"error"})},[x.isError,x.error,a,t]),d.useEffect(()=>{N.isError&&N.error&&a({title:t("dashboard.toast.statusError"),description:N.error.message,variant:"error"})},[N.isError,N.error,a,t]),d.useEffect(()=>{g.isError&&g.error&&a({title:t("dashboard.toast.dbError"),description:g.error.message,variant:"error"})},[g.isError,g.error,a,t]);const xe=d.useCallback(async()=>{if(!l){o(!0);try{await Le.post("/api/db/compact"),await Z(),a({title:t("dashboard.toast.compactSuccess.title"),description:t("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(r){const n=we(r);a({title:t("dashboard.toast.compactError.title"),description:n.message,variant:"error"})}finally{o(!1)}}},[l,a,Z,t]);d.useEffect(()=>{T.isError&&T.error&&a({title:t("dashboard.toast.recentError"),description:T.error.message,variant:"error"})},[T.isError,T.error,a,t]);const i=y.data,C=v.data??[],c=x.data??[],E=N.data,L=g.data,pe=((se=T.data)==null?void 0:se.items)??[],be=L?me(L.totalBytes??L.sizeBytes):"-",ge=me(L==null?void 0:L.memoryRssBytes),te=s==="all"?t("dashboard.filters.endpointAll"):s==="anthropic"?t("dashboard.filters.endpointAnthropic"):s==="openai"?t("dashboard.filters.endpointOpenAI"):((oe=(re=(ae=M.data)==null?void 0:ae.endpoints)==null?void 0:re.find(r=>r.id===s))==null?void 0:oe.label)||s,fe=C.reduce((r,n)=>r+n.requestCount,0),$=C.reduce((r,n)=>!r||n.requestCount>r.requestCount?n:r,null),A=c[0],B=c.filter(r=>r.avgTtftMs!=null&&r.avgTtftMs>0).sort((r,n)=>(r.avgTtftMs??Number.POSITIVE_INFINITY)-(n.avgTtftMs??Number.POSITIVE_INFINITY))[0],je=d.useMemo(()=>{const r=C.map(j=>j.date),n=t("dashboard.charts.barRequests"),m=t("dashboard.charts.lineInput"),_=t("dashboard.charts.lineOutput"),f=t("dashboard.charts.lineCacheRead"),ie=t("dashboard.charts.lineCacheCreation");return{tooltip:{trigger:"axis"},legend:{data:[n,m,_,f,ie]},grid:{left:60,right:40,top:60,bottom:60},xAxis:{type:"category",data:r},yAxis:{type:"value"},series:[{name:n,type:"bar",data:C.map(j=>j.requestCount),itemStyle:{color:S.requests,borderRadius:[4,4,0,0]}},{name:m,type:"line",data:C.map(j=>j.inputTokens),smooth:!0,itemStyle:{color:S.input},lineStyle:{width:2}},{name:_,type:"line",data:C.map(j=>j.outputTokens),smooth:!0,itemStyle:{color:S.output},lineStyle:{width:2}},{name:f,type:"line",data:C.map(j=>j.cacheReadTokens),smooth:!0,itemStyle:{color:S.cacheRead},lineStyle:{width:2}},{name:ie,type:"line",data:C.map(j=>j.cacheCreationTokens),smooth:!0,itemStyle:{color:S.cacheCreation},lineStyle:{width:2}}]}},[C,t]),ye=d.useMemo(()=>{const r=c.map(f=>`${f.provider}/${f.model}`),n=t("dashboard.charts.barRequests"),m=t("dashboard.charts.lineInput"),_=t("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis"},legend:{data:[n,m,_]},grid:{left:80,right:60,top:60,bottom:100},xAxis:{type:"category",data:r,axisLabel:{rotate:30}},yAxis:[{type:"value",name:n},{type:"value",name:t("dashboard.charts.axisTokens"),position:"right"}],series:[{name:n,type:"bar",data:c.map(f=>f.requests),itemStyle:{color:S.requests,borderRadius:[4,4,0,0]}},{name:m,type:"line",yAxisIndex:1,smooth:!0,data:c.map(f=>f.inputTokens??0),itemStyle:{color:S.input}},{name:_,type:"line",yAxisIndex:1,smooth:!0,data:c.map(f=>f.outputTokens??0),itemStyle:{color:S.output}}]}},[c,t]),ve=d.useMemo(()=>{const r=c.map(m=>`${m.provider}/${m.model}`),n=t("dashboard.charts.ttftLabel");return{tooltip:{trigger:"axis"},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:r,axisLabel:{rotate:30}},yAxis:{type:"value",name:t("dashboard.charts.ttftAxis")},series:[{name:n,type:"bar",data:c.map(m=>m.avgTtftMs??0),itemStyle:{color:S.requests,borderRadius:[4,4,0,0]}}]}},[c,t]),Ne=d.useMemo(()=>{const r=c.map(m=>`${m.provider}/${m.model}`),n=t("dashboard.charts.tpotLabel");return{tooltip:{trigger:"axis"},grid:{left:80,right:50,top:60,bottom:100},xAxis:{type:"category",data:r,axisLabel:{rotate:30}},yAxis:{type:"value",name:t("dashboard.charts.tpotAxis")},series:[{name:n,type:"bar",data:c.map(m=>m.avgTpotMs??0),itemStyle:{color:S.output,borderRadius:[4,4,0,0]}}]}},[c,t]);return y.isPending||N.isPending||g.isPending?e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(le,{icon:e.jsx(Q,{className:"h-5 w-5","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description")}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:Array.from({length:6}).map((r,n)=>e.jsx(ke,{},n))}),e.jsx("div",{className:"grid gap-6 lg:grid-cols-2",children:Array.from({length:4}).map((r,n)=>e.jsx(Ee,{},n))}),e.jsx("div",{className:"rounded-[1.25rem] border border-border/70 bg-background/55",children:e.jsx("table",{className:"w-full",children:e.jsx("tbody",{children:Array.from({length:5}).map((r,n)=>e.jsx(Ie,{columns:6},n))})})})]}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(le,{icon:e.jsx(Q,{className:"h-5 w-5","aria-hidden":"true"}),title:t("nav.dashboard"),description:t("dashboard.description"),badge:te,actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t("dashboard.filters.endpoint")}),e.jsxs(qe,{value:s,onValueChange:h,children:[e.jsx(Me,{className:"w-[140px]",children:e.jsx(Ae,{})}),e.jsxs(Be,{children:[e.jsx(F,{value:"all",children:t("dashboard.filters.endpointAll")}),e.jsx(F,{value:"anthropic",children:t("dashboard.filters.endpointAnthropic")}),e.jsx(F,{value:"openai",children:t("dashboard.filters.endpointOpenAI")}),(de=(ne=M.data)==null?void 0:ne.endpoints)==null?void 0:de.map(r=>e.jsx(F,{value:r.id,children:r.label||r.id},r.id))]})]}),e.jsx(ce,{variant:"outline",size:"sm",onClick:()=>void ue(),disabled:ee,children:t(ee?"common.actions.refreshing":"common.actions.refresh")})]})}),E&&e.jsx(Y,{className:"surface-1",children:e.jsxs(K,{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-emerald-300/90 bg-emerald-50 px-3.5 py-2 text-sm shadow-[0_10px_24px_-20px_rgba(5,150,105,0.85)] dark:border-emerald-800 dark:bg-emerald-950/50",children:[e.jsx("span",{className:"font-semibold text-emerald-800 dark:text-emerald-200",children:t("dashboard.status.listeningLabel")}),e.jsxs("span",{className:"font-mono text-[13px] font-semibold tracking-normal text-emerald-950 dark:text-emerald-50",children:[E.host??"0.0.0.0",":",E.port]})]}),e.jsx(q,{variant:"outline",children:te})]}),e.jsx(ce,{variant:"outline",size:"sm",onClick:xe,disabled:l,children:t(l?"dashboard.actions.compacting":"dashboard.actions.compact")})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4 2xl:grid-cols-8",children:[e.jsx(I,{label:t("dashboard.labels.providers"),value:E.providers.toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.activeRequests"),value:(E.activeRequests??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.activeClientAddresses"),value:(E.activeClientAddresses??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.activeClientSessions"),value:(E.activeClientSessions??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.uniqueClientAddressesLastHour"),value:(E.uniqueClientAddressesLastHour??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.uniqueClientSessionsLastHour"),value:(E.uniqueClientSessionsLastHour??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.todayRequests"),value:((i==null?void 0:i.today.requests)??0).toLocaleString()}),e.jsx(I,{label:t("dashboard.labels.database"),value:be}),e.jsx(I,{label:t("dashboard.labels.memory"),value:ge})]})]})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(w,{icon:e.jsx(z,{className:"h-5 w-5"}),title:t("dashboard.cards.todayRequests"),value:(i==null?void 0:i.today.requests)??0,suffix:t("common.units.request"),color:"blue"}),e.jsx(w,{icon:e.jsx(Te,{className:"h-5 w-5"}),title:t("dashboard.cards.todayInput"),value:(i==null?void 0:i.today.inputTokens)??0,suffix:t("common.units.token"),color:"emerald"}),e.jsx(w,{icon:e.jsx(z,{className:"h-5 w-5"}),title:t("dashboard.cards.todayCacheRead"),value:(i==null?void 0:i.today.cacheReadTokens)??0,suffix:t("common.units.token"),color:"violet"}),e.jsx(w,{icon:e.jsx(z,{className:"h-5 w-5"}),title:t("dashboard.cards.todayCacheCreation"),value:(i==null?void 0:i.today.cacheCreationTokens)??0,suffix:t("common.units.token"),color:"rose"}),e.jsx(w,{icon:e.jsx(Q,{className:"h-5 w-5"}),title:t("dashboard.cards.todayOutput"),value:(i==null?void 0:i.today.outputTokens)??0,suffix:t("common.units.token"),color:"amber"}),e.jsx(w,{icon:e.jsx(Ce,{className:"h-5 w-5"}),title:t("dashboard.cards.avgLatency"),value:(i==null?void 0:i.today.avgLatencyMs)??0,suffix:t("common.units.ms"),color:"cyan"})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsx(O,{label:t("dashboard.insights.totalRequests"),value:fe.toLocaleString(),hint:t("dashboard.insights.totalRequestsHint")}),e.jsx(O,{label:t("dashboard.insights.busiestDay"),value:$?`${$.date}`:"-",hint:$?t("dashboard.insights.busiestDayHint",{value:$.requestCount.toLocaleString()}):t("common.noData")}),e.jsx(O,{label:t("dashboard.insights.topModel"),value:A?`${A.provider}/${A.model}`:"-",hint:A?t("dashboard.insights.topModelHint",{value:A.requests.toLocaleString()}):t("common.noData")}),e.jsx(O,{label:t("dashboard.insights.fastestTtft"),value:B?`${B.provider}/${B.model}`:"-",hint:B?P(B.avgTtftMs,t("common.units.ms")):t("common.noData")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(G,{title:t("dashboard.charts.requestsTitle"),description:t("dashboard.charts.requestsDesc"),loading:v.isPending,option:je,empty:!C.length,emptyText:t("dashboard.charts.empty")}),e.jsx(G,{title:t("dashboard.charts.modelTitle"),description:t("dashboard.charts.modelDesc"),loading:x.isPending,option:ye,empty:!c.length,emptyText:t("dashboard.charts.empty")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(G,{title:t("dashboard.charts.ttftTitle"),description:t("dashboard.charts.ttftDesc"),loading:x.isPending,option:ve,empty:!c.some(r=>r.avgTtftMs!=null&&r.avgTtftMs>0),emptyText:t("dashboard.charts.ttftEmpty")}),e.jsx(G,{title:t("dashboard.charts.tpotTitle"),description:t("dashboard.charts.tpotDesc"),loading:x.isPending,option:Ne,empty:!c.some(r=>r.avgTpotMs!=null&&r.avgTpotMs>0),emptyText:t("dashboard.charts.tpotEmpty")})]}),e.jsx(Fe,{models:c,loading:x.isPending}),e.jsx(He,{loading:T.isPending,records:pe})]})}const $e={blue:{gradient:"bg-gradient-to-br from-blue-500/10 via-blue-500/5 to-transparent",iconBg:"bg-blue-500/15",iconColor:"text-blue-600 dark:text-blue-400"},emerald:{gradient:"bg-gradient-to-br from-emerald-500/10 via-emerald-500/5 to-transparent",iconBg:"bg-emerald-500/15",iconColor:"text-emerald-600 dark:text-emerald-400"},amber:{gradient:"bg-gradient-to-br from-amber-500/10 via-amber-500/5 to-transparent",iconBg:"bg-amber-500/15",iconColor:"text-amber-600 dark:text-amber-400"},violet:{gradient:"bg-gradient-to-br from-violet-500/10 via-violet-500/5 to-transparent",iconBg:"bg-violet-500/15",iconColor:"text-violet-600 dark:text-violet-400"},rose:{gradient:"bg-gradient-to-br from-rose-500/10 via-rose-500/5 to-transparent",iconBg:"bg-rose-500/15",iconColor:"text-rose-600 dark:text-rose-400"},cyan:{gradient:"bg-gradient-to-br from-cyan-500/10 via-cyan-500/5 to-transparent",iconBg:"bg-cyan-500/15",iconColor:"text-cyan-600 dark:text-cyan-400"}};function w({icon:t,title:a,value:s,suffix:h,color:l="blue"}){const o=$e[l];return e.jsx(Y,{variant:"interactive",className:k("overflow-hidden",o.gradient),children:e.jsxs(K,{className:"pt-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:a}),t&&e.jsx("div",{className:k("flex h-10 w-10 items-center justify-center rounded-xl",o.iconBg,o.iconColor),children:t})]}),e.jsxs("p",{className:"text-3xl font-bold tracking-tight",children:[s.toLocaleString(),h&&e.jsx("span",{className:"ml-1.5 text-sm font-medium text-muted-foreground",children:h})]})]})})}function I({label:t,value:a}){return e.jsxs("div",{className:"rounded-2xl border border-border/70 bg-background/70 px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:t}),e.jsx("p",{className:"mt-2 text-lg font-semibold",children:a})]})}function O({label:t,value:a,hint:s}){return e.jsxs("div",{className:"rounded-[1.3rem] border border-white/50 bg-card/90 px-4 py-4 shadow-[0_1px_2px_rgba(15,23,42,0.03)] backdrop-blur",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:t}),e.jsx("p",{className:"mt-2 line-clamp-1 text-sm font-semibold",children:a}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s})]})}function G({title:t,description:a,option:s,loading:h,empty:l,emptyText:o}){const{t:u}=V();return e.jsx(Y,{className:"surface-1",children:e.jsxs(K,{className:"space-y-4 pt-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-semibold",children:t}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a})]}),h?e.jsx("div",{className:"flex min-h-[280px] h-[40vh] max-h-[420px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:u("common.loadingShort")})}):l?e.jsxs("div",{className:"flex min-h-[280px] h-[40vh] max-h-[420px] flex-col items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:[e.jsx(Q,{className:"mb-2 h-10 w-10 text-muted-foreground/50"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:o??u("dashboard.charts.empty")})]}):e.jsx(Se,{echarts:_e,option:s,className:"min-h-[280px] h-[40vh] max-h-[420px]",notMerge:!0,lazyUpdate:!0})]})})}function Fe({models:t,loading:a}){const{t:s}=V(),h=t.length>0;return e.jsx(he,{title:s("dashboard.modelTable.title"),description:s("dashboard.modelTable.description"),children:a?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.loadingShort")})}):h?e.jsx("div",{className:"max-h-80 overflow-auto rounded-[1.2rem]",children:e.jsxs(J,{children:[e.jsx(W,{children:e.jsxs(D,{children:[e.jsx(p,{children:s("dashboard.modelTable.columns.model")}),e.jsx(p,{className:"text-right",children:s("dashboard.modelTable.columns.requests")}),e.jsx(p,{className:"text-right",children:s("dashboard.modelTable.columns.latency")}),e.jsx(p,{className:"text-right",children:s("dashboard.modelTable.columns.ttft")}),e.jsx(p,{className:"text-right",children:s("dashboard.modelTable.columns.tpot")})]})}),e.jsx(X,{children:t.map(l=>e.jsxs(D,{children:[e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:l.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:l.model})]})}),e.jsx(b,{className:"text-right font-medium",children:l.requests.toLocaleString()}),e.jsx(b,{className:"text-right",children:P(l.avgLatencyMs,s("common.units.ms"))}),e.jsx(b,{className:"text-right",children:P(l.avgTtftMs,s("common.units.ms"))}),e.jsx(b,{className:"text-right",children:P(l.avgTpotMs,s("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${l.provider}/${l.model}`))})]})}):e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard.modelTable.empty")})})})}function He({records:t,loading:a}){const{t:s}=V(),h=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:s("dashboard.recent.title"),description:s("dashboard.recent.subtitle",{count:5}),children:a?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard.recent.loading")})}):t.length===0?e.jsx("div",{className:"flex h-32 items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard.recent.empty")})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(q,{variant:"secondary",children:t.length}),e.jsxs(q,{variant:"outline",className:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",children:[s("common.status.success"),": ",h]}),e.jsxs(q,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[s("common.status.error"),": ",l]})]}),e.jsx("div",{className:"max-h-80 overflow-auto rounded-[1.2rem]",children:e.jsxs(J,{children:[e.jsx(W,{children:e.jsxs(D,{children:[e.jsx(p,{children:s("dashboard.recent.columns.time")}),e.jsx(p,{children:s("dashboard.recent.columns.endpoint")}),e.jsx(p,{children:s("dashboard.recent.columns.provider")}),e.jsx(p,{children:s("dashboard.recent.columns.route")}),e.jsx(p,{className:"text-right",children:s("dashboard.recent.columns.latency")}),e.jsx(p,{children:s("dashboard.recent.columns.status")})]})}),e.jsx(X,{children:t.map(o=>e.jsxs(D,{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(q,{variant:"outline",className:"text-[11px]",children:o.endpoint==="anthropic"?s("logs.table.endpointAnthropic"):o.endpoint==="openai"?s("logs.table.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??s("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"→"}),e.jsx("span",{className:"font-medium text-foreground",children:o.model})]}),o.error?e.jsx("span",{className:"truncate text-destructive",children:o.error}):null]})}),e.jsx(b,{className:"text-right font-medium",children:P(o.latency_ms,s("common.units.ms"))}),e.jsx(b,{children:e.jsx(q,{variant:o.error?"destructive":"default",className:"min-w-14 justify-center",children:(o.status_code??(o.error?500:200)).toString()})})]},o.id))})]})})]})})}export{rt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,f as e,ag as $,N as L,ad as R,ah as T,ai as I}from"./vendor-C92xTG6Z.js";import{u as z,B as x,c as w,L as P,e as F,t as B}from"./index-
|
|
1
|
+
import{r as i,f as e,ag as $,N as L,ad as R,ah as T,ai as I}from"./vendor-C92xTG6Z.js";import{u as z,B as x,c as w,L as P,e as F,t as B}from"./index-BuTkie0t.js";import{P as V,B as u}from"./PageHeader-Da1cmUY0.js";import{I as D}from"./input-BHq9dQGf.js";import{C,a as S,b as K}from"./card-BD2y3CjZ.js";import{S as H,a as J,b as O,c as U,d as v}from"./select-Dq7kCMCk.js";import{u as _}from"./i18n-CZ1qKIdj.js";import"./router-DjNibHfR.js";import"./radix-Ccu1urVd.js";import"./query-CDpWKdnY.js";function q(t){const l=Date.now()-t,n=Math.abs(l),m=60*1e3,d=60*m,o=24*d;if(n<m){const r=Math.max(Math.round(n/1e3),1);return l>=0?`${r}s ago`:`in ${r}s`}if(n<d){const r=Math.round(n/m);return l>=0?`${r}m ago`:`in ${r}m`}if(n<o){const r=Math.round(n/d);return l>=0?`${r}h ago`:`in ${r}h`}const h=Math.round(n/o);return l>=0?`${h}d ago`:`in ${h}d`}function G(t){return new Date(t).toLocaleString()}const Q={info:"secondary",warn:"outline",error:"destructive"};function ne(){const{t}=_(),{pushToast:g}=z(),[l,n]=i.useState([]),[m,d]=i.useState(!0),[o,h]=i.useState(null),[r,A]=i.useState(null),[a,j]=i.useState({level:"",type:""}),[N,y]=i.useState(!1),f=async s=>{d(!0);try{const c=await F.list({cursor:(s==null?void 0:s.cursor)??void 0,limit:50,level:a.level||void 0,type:a.type||void 0});n(c.events),A(c.nextCursor),h((s==null?void 0:s.cursor)??null)}catch(c){const M=B(c);g({title:t("events.toast.loadFailure",{message:M.message}),variant:"error"})}finally{d(!1),y(!1)}};i.useEffect(()=>{f({reset:!0})},[a.level,a.type]);const k=()=>{y(!0),f({cursor:o,reset:!1})},b=()=>{j({level:"",type:""})},E=i.useMemo(()=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",disabled:!o,onClick:()=>void f({cursor:void 0}),children:[e.jsx($,{className:"mr-1 h-4 w-4"})," ",t("events.actions.newest")]}),e.jsxs(x,{variant:"outline",size:"sm",disabled:!r,onClick:()=>void f({cursor:r??void 0}),children:[t("events.actions.older")," ",e.jsx(L,{className:"ml-1 h-4 w-4"})]})]}),[o,r,t]),p=i.useMemo(()=>{const s=[];return a.level&&s.push(t(`events.levels.${a.level}`)),a.type.trim()&&s.push(a.type.trim()),s},[a.level,a.type,t]);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(V,{icon:e.jsx(T,{className:"h-5 w-5"}),title:t("events.title"),description:t("events.description"),actions:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.jsxs(x,{variant:"outline",size:"sm",onClick:k,disabled:N,children:[e.jsx(R,{className:w("mr-2 h-4 w-4",N&&"animate-spin")}),t(N?"common.actions.refreshing":"common.actions.refresh")]})})}),e.jsx(C,{className:"sticky top-20 z-20 surface-1",children:e.jsx(S,{className:"pt-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm: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(I,{className:"h-4 w-4 text-primary"}),t("events.filters.title"),e.jsx(u,{variant:"outline",children:l.length})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("events.description")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.length>0&&e.jsx(x,{variant:"ghost",size:"sm",onClick:b,children:t("common.actions.reset")}),E]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(H,{value:a.level,onValueChange:s=>j(c=>({...c,level:s==="all"?"":s})),children:[e.jsx(J,{className:"w-[140px]",children:e.jsx(O,{placeholder:t("events.filters.allLevels")})}),e.jsxs(U,{children:[e.jsx(v,{value:"all",children:t("events.filters.allLevels")}),e.jsx(v,{value:"info",children:t("events.levels.info")}),e.jsx(v,{value:"warn",children:t("events.levels.warn")}),e.jsx(v,{value:"error",children:t("events.levels.error")})]})]}),e.jsx(D,{className:"w-[180px]",placeholder:t("events.filters.typePlaceholder"),value:a.type,onChange:s=>j(c=>({...c,type:s.target.value}))}),e.jsx(x,{variant:"ghost",size:"sm",onClick:b,disabled:p.length===0,children:t("common.actions.reset")})]}),p.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(s=>e.jsx(u,{variant:"secondary",children:s},s))})]})})}),m?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(P,{})}):l.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center rounded-[1.25rem] border border-dashed border-border/70 bg-background/45 p-10 text-center",children:[e.jsx("p",{className:"text-base font-medium",children:t("events.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t("events.empty.subtitle")})]}):e.jsx("div",{className:"grid gap-4",children:l.map(s=>e.jsxs(C,{className:w("overflow-hidden border-l-4",s.level==="error"?"border-l-destructive":s.level==="warn"?"border-l-amber-500":"border-l-emerald-500"),children:[e.jsx(K,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(u,{variant:Q[s.level]||"secondary",children:t(`events.levels.${s.level}`)}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[G(s.createdAt)," · ",q(s.createdAt)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(u,{variant:"outline",children:["#",s.id]}),s.mode&&e.jsx(u,{variant:"secondary",children:s.mode})]})]})}),e.jsxs(S,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-base font-semibold",children:s.title||t("events.defaultTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.message||t("events.defaultMessage")})]}),e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2 lg:grid-cols-3",children:[s.ipAddress&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"IP"}),e.jsx("p",{children:s.ipAddress})]}),s.apiKeyName&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"API Key"}),e.jsx("p",{children:s.apiKeyName})]}),s.userAgent&&e.jsxs("div",{className:"space-y-1 sm:col-span-2 lg:col-span-3",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"User Agent"}),e.jsx("p",{className:"truncate",children:s.userAgent})]})]}),s.details&&e.jsxs("details",{className:"rounded-[1rem] border border-border/70 bg-background/45 p-3 text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-primary",children:t("events.details")}),e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-[1rem] border border-border/70 bg-background/70 p-3 text-xs",children:JSON.stringify(s.details,null,2)})]})]})]},s.id))})]})}export{ne as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as h,f as e,au as b,as as N,av as v,aw as w}from"./vendor-C92xTG6Z.js";import{P as y}from"./PageHeader-
|
|
1
|
+
import{r as h,f as e,au as b,as as N,av as v,aw as w}from"./vendor-C92xTG6Z.js";import{P as y}from"./PageHeader-Da1cmUY0.js";import{P as d}from"./PageSection-Bf8b2jG0.js";import{c as u}from"./clipboard-CALi6bTW.js";import{C as p,a as j}from"./card-BD2y3CjZ.js";import{B as f}from"./index-BuTkie0t.js";import{u as x}from"./i18n-CZ1qKIdj.js";import"./router-DjNibHfR.js";import"./radix-Ccu1urVd.js";import"./query-CDpWKdnY.js";function $(){const{t:s}=x(),t=h.useMemo(()=>{const i=s("help.sections.configuration.items",{returnObjects:!0}),a=s("help.sections.claudeCodeConfig.items",{returnObjects:!0}),n=s("help.sections.codexConfig.items",{returnObjects:!0}),c=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:a},{title:s("help.sections.codexConfig.title"),items:n},{title:s("help.sections.usage.title"),items:c},{title:s("help.sections.tips.title"),items:g}]},[s]),r=s("help.faq.items",{returnObjects:!0}),l=h.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(y,{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")}),e.jsx(p,{className:"surface-1",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-2xl bg-primary/10 text-primary shadow-[inset_0_0_0_1px_rgba(59,130,246,0.08)]",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-[1.35rem] border border-white/50 bg-card/88 px-4 py-4 shadow-[0_1px_2px_rgba(15,23,42,0.03)] transition hover:-translate-y-0.5 hover:shadow-[0_12px_36px_-24px_rgba(15,23,42,0.3)]",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(d,{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(d,{eyebrow:"02",title:t[1].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-xl bg-primary/5 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(d,{eyebrow:"03",title:t[2].title,children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-xl bg-emerald-500/5 p-4 dark:bg-emerald-500/10",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-500 text-white",children:e.jsx(w,{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(d,{eyebrow:"04",title:t[3].title,children:e.jsx(o,{items:t[3].items})}),e.jsx(d,{eyebrow:"05",title:t[4].title,children:e.jsx(o,{items:t[4].items})})]})]})]}),e.jsx("div",{id:"help-faq",children:e.jsx(d,{eyebrow:"FAQ",title:s("help.faq.title"),children:e.jsx(_,{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-[1.2rem] border border-white/50 bg-card/82 p-3 shadow-[0_1px_2px_rgba(15,23,42,0.03)]",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[a,...n]=l.split(`
|
|
2
2
|
`),c=n.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:a||"bash"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>u(c),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto rounded-[1rem] border border-border/70 bg-background/70 p-3 text-xs",children:e.jsx("code",{children:c})})]},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 _({items:s}){return s.length===0?null:e.jsx("dl",{className:"flex flex-col gap-3",children:s.map(t=>e.jsx(p,{className:"surface-1",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,f as e}from"./vendor-C92xTG6Z.js";import{i as C,h as E,B as F}from"./index-
|
|
1
|
+
import{r as n,f as e}from"./vendor-C92xTG6Z.js";import{i as C,h as E,B as F}from"./index-BuTkie0t.js";import{I as j}from"./input-BHq9dQGf.js";import{L as b}from"./label-CUv6yhdE.js";import{C as v,a as w,b as S,c as L,d as k,e as _}from"./card-BD2y3CjZ.js";import{u as P}from"./i18n-CZ1qKIdj.js";import{c as T,u as A}from"./router-DjNibHfR.js";import"./radix-Ccu1urVd.js";import"./query-CDpWKdnY.js";function z(){const{t:s}=P(),i=T(),m=A(),{authEnabled:o,isAuthenticated:u,loading:l,login:y,error:p}=C(),[a,x]=n.useState({username:"",password:""}),[f,d]=n.useState(null),[h,g]=n.useState(!1),c=n.useMemo(()=>{var t;const r=m.state;return((t=r==null?void 0:r.from)==null?void 0:t.pathname)??"/"},[m.state]);n.useEffect(()=>{if(!o&&!l){i(c,{replace:!0});return}o&&u&&!l&&i(c,{replace:!0})},[o,u,l,i,c]);const N=async r=>{if(r.preventDefault(),d(null),!a.username.trim()||!a.password){d(s("login.validation.required"));return}g(!0);try{await y(a.username.trim(),a.password),i(c,{replace:!0})}catch(t){d(t instanceof Error?t.message:s("login.validation.failed"))}finally{g(!1)}};return l?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsx(v,{className:"surface-2 w-full max-w-md",children:e.jsx(w,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(E,{})})})}):o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsxs(v,{className:"surface-2 w-full max-w-md overflow-hidden",children:[e.jsxs(S,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-[1.15rem] bg-gradient-to-br from-primary via-primary to-sky-400 text-lg font-bold text-primary-foreground shadow-[0_14px_30px_-18px_rgba(59,130,246,0.75)]",children:"GW"}),e.jsx(L,{className:"text-2xl",children:s("login.title")}),e.jsx(k,{className:"text-sm",children:s("login.description")})]}),e.jsx(w,{children:e.jsxs("form",{className:"space-y-4",onSubmit:N,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(j,{id:"username",value:a.username,autoComplete:"username",autoFocus:!0,onChange:r=>x(t=>({...t,username:r.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(j,{id:"password",type:"password",value:a.password,autoComplete:"current-password",onChange:r=>x(t=>({...t,password:r.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),(f||p)&&e.jsx("div",{className:"rounded-[1rem] border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:f||p}),e.jsx(F,{type:"submit",className:"w-full",disabled:h,children:s(h?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(_,{className:"justify-center",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})}):null}export{z as default};
|