@chenpu17/cc-gw 0.8.0-alpha.0 → 0.8.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +5 -5
- package/src/web/dist/assets/{About-g7O_JA6K.js → About-CiTmsH3_.js} +1 -1
- package/src/web/dist/assets/ApiKeys-6rCCLhIC.js +1 -0
- package/src/web/dist/assets/{ConfirmDialog-DwZk3ejq.js → ConfirmDialog-A9gywPpz.js} +1 -1
- package/src/web/dist/assets/Dashboard-BoZHGcx0.js +1 -0
- package/src/web/dist/assets/EChart-C_zeFtIj.js +1 -0
- package/src/web/dist/assets/{Events-D7p4pym8.js → Events-DAiVr1Fh.js} +1 -1
- package/src/web/dist/assets/Help-5dtFavzf.js +8 -0
- package/src/web/dist/assets/{Login-h9CRbinI.js → Login-Bf2fjws1.js} +1 -1
- package/src/web/dist/assets/Logs-63hL3C0b.js +1 -0
- package/src/web/dist/assets/ModelManagement-Sh2TbDu3.js +1 -0
- package/src/web/dist/assets/PageHeader-BfplRrls.js +1 -0
- package/src/web/dist/assets/PageSection-DLrvM7lY.js +1 -0
- package/src/web/dist/assets/Settings-I4pHQi8Z.js +1 -0
- package/src/web/dist/assets/{Skeleton-DFeA7kZw.js → Skeleton-m_JcEeRW.js} +1 -1
- package/src/web/dist/assets/{card-DRsnBFyp.js → card-pQJ3gJlC.js} +1 -1
- package/src/web/dist/assets/{charts-core-BjxPMAw_.js → charts-core-BE9sa9zn.js} +1 -1
- package/src/web/dist/assets/{charts-engine-B4YVo-Wh.js → charts-engine-DAwKT7Yg.js} +1 -1
- package/src/web/dist/assets/{charts-react-BxiU3S4Y.js → charts-react-Dnkr-ZWt.js} +1 -1
- package/src/web/dist/assets/{i18n-qAxAISVU.js → i18n-CZ1qKIdj.js} +1 -1
- package/src/web/dist/assets/index-CB0xlluu.js +61 -0
- package/src/web/dist/assets/index-NGg4j8sr.css +1 -0
- package/src/web/dist/assets/{input-BCUUQfiv.js → input-DmlfmLRF.js} +1 -1
- package/src/web/dist/assets/{label-CtuP7N6a.js → label-WnrqWaUM.js} +1 -1
- package/src/web/dist/assets/popover-BGLA6gjb.js +1 -0
- package/src/web/dist/assets/{query-BnTlXVsy.js → query-CDpWKdnY.js} +1 -1
- package/src/web/dist/assets/{radix-CwKvZelb.js → radix-Ccu1urVd.js} +2 -2
- package/src/web/dist/assets/{router-Ju3lwB-M.js → router-DjNibHfR.js} +1 -1
- package/src/web/dist/assets/{select-C-e-41FP.js → select-f3RCxJ98.js} +1 -1
- package/src/web/dist/assets/{switch-D72iMnTO.js → switch-BSgZEVkb.js} +1 -1
- package/src/web/dist/assets/{useApiQuery-C4-HjWYY.js → useApiQuery-BGQDgPyp.js} +1 -1
- package/src/web/dist/assets/{vendor-UrUELLAG.js → vendor-C92xTG6Z.js} +1 -1
- package/src/web/dist/index.html +7 -7
- package/src/web/dist/assets/ApiKeys-CEJ9-jBz.js +0 -1
- package/src/web/dist/assets/Dashboard-OPVlXupp.js +0 -1
- package/src/web/dist/assets/EChart-CfTG8iSv.js +0 -1
- package/src/web/dist/assets/Help-DbNTCxxV.js +0 -8
- package/src/web/dist/assets/Logs-DN-Cl2dm.js +0 -1
- package/src/web/dist/assets/ModelManagement-CrpcomEc.js +0 -1
- package/src/web/dist/assets/PageHeader-CbpaEUEn.js +0 -1
- package/src/web/dist/assets/PageSection-6q9HngU5.js +0 -1
- package/src/web/dist/assets/Settings-Bp_GpSh3.js +0 -1
- package/src/web/dist/assets/index-BKEgpvTe.js +0 -61
- package/src/web/dist/assets/index-BfFWdxjR.css +0 -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.2.tgz
|
|
122
|
+
npm install -g ./.pack/chenpu17-cc-gw-0.8.0-alpha.2.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.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Rust-backed local Claude Code compatible gateway with web console and CLI daemon.",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"optionalDependencies": {
|
|
28
|
-
"@chenpu17/cc-gw-
|
|
29
|
-
"@chenpu17/cc-gw-
|
|
30
|
-
"@chenpu17/cc-gw-
|
|
31
|
-
"@chenpu17/cc-gw-
|
|
28
|
+
"@chenpu17/cc-gw-darwin-arm64": "0.8.0-alpha.2",
|
|
29
|
+
"@chenpu17/cc-gw-linux-arm64": "0.8.0-alpha.2",
|
|
30
|
+
"@chenpu17/cc-gw-linux-x64": "0.8.0-alpha.2",
|
|
31
|
+
"@chenpu17/cc-gw-win32-x64": "0.8.0-alpha.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"colorette": "^2.0.20",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,f as e,
|
|
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-BGQDgPyp.js";import{u as C,B as j}from"./index-CB0xlluu.js";import{P as S,B as o}from"./PageHeader-BfplRrls.js";import{P as d}from"./PageSection-DLrvM7lY.js";import{C as N,a as y}from"./card-pQJ3gJlC.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.2",V={version:P},M={VITE_BUILD_TIME:"2026-03-14T11:45:28.673Z"};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};
|
|
@@ -0,0 +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 +1 @@
|
|
|
1
|
-
import{r,f as a,
|
|
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-CB0xlluu.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};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as a}from"./charts-react-Dnkr-ZWt.js";import{u as s,i as l,a as t,b as i,c as n,d as o,f as r,g as $}from"./charts-core-BE9sa9zn.js";s([l,t,i,n,o,r,$]);const e=a;export{e as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,f as e,
|
|
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-CB0xlluu.js";import{P as V,B as u}from"./PageHeader-BfplRrls.js";import{I as D}from"./input-DmlfmLRF.js";import{C,a as S,b as K}from"./card-pQJ3gJlC.js";import{S as H,a as J,b as O,c as U,d as v}from"./select-f3RCxJ98.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};
|
|
@@ -0,0 +1,8 @@
|
|
|
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-BfplRrls.js";import{P as d}from"./PageSection-DLrvM7lY.js";import{c as u}from"./clipboard-CALi6bTW.js";import{C as p,a as j}from"./card-pQJ3gJlC.js";import{B as f}from"./index-CB0xlluu.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
|
+
`),c=n.join(`
|
|
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
|
+
`)?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(`
|
|
5
|
+
`).filter(i=>i.trim());if(r.some(i=>/^\d+\)/.test(i.trim())))return e.jsx("div",{className:"space-y-1",children:r.map((i,a)=>{const n=i.match(/^\d+\)\s*(.*)/);return n?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"•"}),e.jsx("span",{children:n[1]})]},a):e.jsx("div",{children:i},a)})})}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:l},i):null;{const[a,...n]=l.split(`
|
|
6
|
+
`),c=n.join(`
|
|
7
|
+
`);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(`
|
|
8
|
+
`)?e.jsx("div",{className:"whitespace-pre-line",children:s}):e.jsx("div",{children:s})}export{$ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,f as e}from"./vendor-
|
|
1
|
+
import{r as n,f as e}from"./vendor-C92xTG6Z.js";import{i as C,h as E,B as F}from"./index-CB0xlluu.js";import{I as j}from"./input-DmlfmLRF.js";import{L as b}from"./label-WnrqWaUM.js";import{C as v,a as w,b as S,c as L,d as k,e as _}from"./card-pQJ3gJlC.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o,f as e,ac as Ze,ad as Xe,Z as es,ae as ss,af as ts,a5 as Fe,h as as}from"./vendor-C92xTG6Z.js";import{u as Ke,a as ls,t as rs,c as h,B as y}from"./index-CB0xlluu.js";import{u as A}from"./useApiQuery-BGQDgPyp.js";import{T as os,a as Q}from"./Skeleton-m_JcEeRW.js";import{P as ns,B as P}from"./PageHeader-BfplRrls.js";import{c as is}from"./clipboard-CALi6bTW.js";import{I as me}from"./input-DmlfmLRF.js";import{L as O}from"./label-WnrqWaUM.js";import{C as Re,a as De}from"./card-pQJ3gJlC.js";import{S as Z,a as X,b as ee,c as se,d as T}from"./select-f3RCxJ98.js";import{P as ds,a as cs,b as ms}from"./popover-BGLA6gjb.js";import{u as ae}from"./i18n-CZ1qKIdj.js";import"./router-DjNibHfR.js";import"./radix-Ccu1urVd.js";import"./query-CDpWKdnY.js";const Me=[20,50,100],ze="cc-gw.logs.visible-columns",Ae="cc-gw.logs.density",$=["endpoint","provider","requestedModel","routedModel","apiKey","inputTokens","outputTokens","latency","status","error"],te=["endpoint","provider","requestedModel","routedModel","apiKey","inputTokens","cacheReadTokens","cacheCreationTokens","outputTokens","latency","ttft","tpot","status","error"];function xs(){if(typeof window>"u")return $;try{const s=window.localStorage.getItem(ze);if(!s)return $;const i=JSON.parse(s);if(!Array.isArray(i))return $;const c=i.filter(v=>te.includes(v));return c.length>0?c:$}catch{return $}}function us(){return typeof window>"u"?"comfortable":window.localStorage.getItem(Ae)==="compact"?"compact":"comfortable"}function Oe(s,i=!1){if(!s)return;const c=i?`${s}T23:59:59.999`:`${s}T00:00:00.000`,v=Date.parse(c);return Number.isFinite(v)?v:void 0}function Pe(s){const i=new Date(s);return`${i.getFullYear()}-${`${i.getMonth()+1}`.padStart(2,"0")}-${`${i.getDate()}`.padStart(2,"0")} ${`${i.getHours()}`.padStart(2,"0")}:${`${i.getMinutes()}`.padStart(2,"0")}:${`${i.getSeconds()}`.padStart(2,"0")}`}function L(s){return s==null?"-":s.toLocaleString()}function C(s,i){const c=L(s);return c==="-"?"-":`${c} ${i}`}function ps(s){return s?"true":"false"}function $e(s,i){if(!s||s.trim().length===0)return i;try{const c=JSON.parse(s);return JSON.stringify(c,null,2)}catch{return s}}function hs(s,i,c){return s===c&&i===c}function Os(){var ke,_e,Se,Ee,Te,Ce;const{t:s}=ae(),{pushToast:i}=Ke(),[c,v]=o.useState("all"),[g,a]=o.useState("all"),[d,j]=o.useState(""),[x,N]=o.useState("all"),[l,S]=o.useState(""),[r,m]=o.useState(""),[f,p]=o.useState(1),[u,F]=o.useState(Me[0]),[le,I]=o.useState(null),[Ie,xe]=o.useState(!1),[w,re]=o.useState([]),[H,ue]=o.useState(!1),[pe,qe]=o.useState(!1),[q,he]=o.useState(us),[R,fe]=o.useState(xs),[Ue,Ge]=o.useState(!1),oe=o.useRef(null);o.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Ae,q)},[q]),o.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(ze,JSON.stringify(R))},[R]),o.useEffect(()=>{p(1)},[c,g,d,x,l,r,u,w]);const W=o.useMemo(()=>{const t={limit:u,offset:(f-1)*u};c!=="all"&&(t.provider=c),g!=="all"&&(t.endpoint=g),d.trim().length>0&&(t.model=d.trim()),x!=="all"&&(t.status=x);const n=Oe(l),_=Oe(r,!0);return n!==void 0&&(t.from=n),_!==void 0&&(t.to=_),w.length>0&&(t.apiKeys=w.join(",")),t},[c,g,d,x,l,r,f,u,w]),k=A(["logs",W],{url:"/api/logs",method:"GET",params:W}),K=A(["providers","all"],{url:"/api/providers",method:"GET"}),ge=A(["api-keys"],{url:"/api/keys",method:"GET"}),ne=A(["custom-endpoints"],{url:"/api/custom-endpoints",method:"GET"}),je=A(["config","export-timeout"],{url:"/api/config",method:"GET"});o.useEffect(()=>{k.isError&&k.error&&i({title:s("logs.toast.listError.title"),description:s("logs.toast.listError.desc",{message:k.error.message}),variant:"error"})},[k.isError,k.error,i,s]),o.useEffect(()=>{K.isError&&K.error&&i({title:s("logs.toast.providerError.title"),description:s("logs.toast.providerError.desc",{message:K.error.message}),variant:"error"})},[K.isError,K.error,i,s]);const D=((ke=k.data)==null?void 0:ke.total)??0,E=D>0?Math.ceil(D/u):0,be=((_e=k.data)==null?void 0:_e.items)??[],ye=o.useMemo(()=>{var n;const t=(n=je.data)==null?void 0:n.logExportTimeoutSeconds;return typeof t=="number"&&Number.isFinite(t)?Math.min(Math.max(Math.round(t),5),600)*1e3:6e4},[(Se=je.data)==null?void 0:Se.logExportTimeoutSeconds]);o.useEffect(()=>{E>0&&f>E&&p(E)},[E,f]);const ie=K.data??[],J=o.useMemo(()=>{const t=new Map;for(const n of ie)n.id&&t.set(n.id,n.label??n.id);return t},[ie]),ve=o.useMemo(()=>{var n;const t=new Map;t.set("anthropic",s("logs.filters.endpointAnthropic")),t.set("openai",s("logs.filters.endpointOpenAI"));for(const _ of((n=ne.data)==null?void 0:n.endpoints)??[])t.set(_.id,_.label||_.id);return t},[(Ee=ne.data)==null?void 0:Ee.endpoints,s]),z=o.useMemo(()=>{const t=[];if(c!=="all"){const n=J.get(c)??c;t.push({key:"provider",label:`${s("logs.filters.provider")}: ${n}`,onRemove:()=>v("all")})}if(g!=="all"){const n=ve.get(g)??g;t.push({key:"endpoint",label:`${s("logs.filters.endpoint")}: ${n}`,onRemove:()=>a("all")})}if(d.trim()&&t.push({key:"model",label:`${s("logs.filters.modelId")}: ${d.trim()}`,onRemove:()=>j("")}),x!=="all"){const n=s(x==="success"?"logs.filters.statusSuccess":"logs.filters.statusError");t.push({key:"status",label:`${s("logs.filters.status")}: ${n}`,onRemove:()=>N("all")})}return l&&t.push({key:"from",label:`${s("logs.filters.startDate")}: ${l}`,onRemove:()=>S("")}),r&&t.push({key:"to",label:`${s("logs.filters.endDate")}: ${r}`,onRemove:()=>m("")}),w.length>0&&t.push({key:"apiKeys",label:s("logs.filters.apiKeySelected",{count:w.length}),onRemove:()=>re([])}),t},[c,J,g,ve,d,x,l,r,w,s]),de=ge.data??[],Ne=o.useMemo(()=>{const t=new Map;for(const n of de)t.set(n.id,n);return t},[de]),b=o.useMemo(()=>new Set(R),[R]),Be=o.useMemo(()=>te.map(t=>({id:t,label:s(`logs.table.columns.${t}`)})),[s]),we=R.length+2,U=o.useMemo(()=>new Date().toISOString().slice(0,10),[]),Ve=o.useMemo(()=>c==="all"&&g==="all"&&d.trim()===""&&x==="all"&&l===""&&r===""&&w.length===0?"all":x==="error"&&g==="all"&&c==="all"&&d.trim()===""&&l===""&&r===""&&w.length===0?"errors":hs(l,r,U)&&g==="all"&&c==="all"&&d.trim()===""&&x==="all"&&w.length===0?"today":g==="anthropic"&&c==="all"&&d.trim()===""&&x==="all"&&l===""&&r===""&&w.length===0?"anthropic":g==="openai"&&c==="all"&&d.trim()===""&&x==="all"&&l===""&&r===""&&w.length===0?"openai":null,[g,l,d,c,w.length,x,r,U]),Qe=o.useCallback(t=>{fe(n=>{if(n.includes(t))return n.length===1?n:n.filter(B=>B!==t);const _=[...n,t];return _.sort((B,ce)=>te.indexOf(B)-te.indexOf(ce)),_})},[]),Y=o.useCallback(()=>{v("all"),j(""),a("all"),N("all"),S(""),m(""),re([])},[]),He=o.useCallback(t=>{if(p(1),Y(),t!=="all"){if(t==="errors"){N("error");return}if(t==="today"){S(U),m(U);return}if(t==="anthropic"){a("anthropic");return}t==="openai"&&a("openai")}},[Y,U]),We=o.useCallback(async()=>{if(!H){ue(!0);try{const t=D>0?Math.min(D,5e3):1e3,n={...W,limit:t,offset:0},_=await ls.post("/api/logs/export",n,{responseType:"blob",timeout:ye}),B=new Blob([_.data],{type:"application/zip"}),ce=new Date().toISOString().replace(/[:.]/g,"-"),Le=URL.createObjectURL(B),V=document.createElement("a");V.href=Le,V.download=`cc-gw-logs-${ce}.zip`,document.body.appendChild(V),V.click(),V.remove(),URL.revokeObjectURL(Le),i({title:s("logs.toast.exportSuccess.title"),description:s("logs.toast.exportSuccess.desc"),variant:"success"})}catch(t){const n=rs(t);i({title:s("logs.toast.exportError.title"),description:s("logs.toast.exportError.desc",{message:n.message}),variant:"error"})}finally{ue(!1)}}},[ye,H,i,W,s,D]),Je=o.useCallback(t=>{I(t),xe(!0)},[]),Ye=o.useCallback(()=>{xe(!1),I(null)},[]),G=o.useCallback(()=>{const t=oe.current;if(!t)return;const n=t.scrollWidth-t.scrollLeft-t.clientWidth>1;Ge(n)},[]);return o.useEffect(()=>{const t=oe.current;if(!t)return;G(),t.addEventListener("scroll",G,{passive:!0});const n=new ResizeObserver(G);return n.observe(t),()=>{t.removeEventListener("scroll",G),n.disconnect()}},[G]),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ns,{icon:e.jsx(es,{className:"h-5 w-5","aria-hidden":"true"}),title:s("logs.title"),description:s("logs.description"),eyebrow:"Traffic Explorer",breadcrumb:"Gateway / Logs",helper:s("logs.filtersDescription"),actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("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:[e.jsx("button",{type:"button",onClick:()=>he("comfortable"),className:h("inline-flex h-8 items-center rounded-full px-3.5 text-xs font-medium transition-all",q==="comfortable"?"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:s("logs.table.density.comfortable")}),e.jsx("button",{type:"button",onClick:()=>he("compact"),className:h("inline-flex h-8 items-center rounded-full px-3.5 text-xs font-medium transition-all",q==="compact"?"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:s("logs.table.density.compact")})]}),e.jsxs(ds,{children:[e.jsx(cs,{asChild:!0,children:e.jsx(y,{variant:"outline",size:"sm",children:s("logs.actions.columns")})}),e.jsxs(ms,{align:"end",className:"w-64 rounded-[1.2rem] border-white/60 p-3",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:s("logs.actions.columns")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("logs.actions.visibleCount",{count:R.length})})]}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>fe($),disabled:JSON.stringify(R)===JSON.stringify($),children:s("common.actions.reset")})]}),e.jsx("div",{className:"grid gap-1.5",children:Be.map(t=>{const n=b.has(t.id);return e.jsxs("label",{className:h("flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2 text-sm transition hover:bg-primary/5",n&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",checked:n,onChange:()=>Qe(t.id),className:"h-4 w-4 rounded border-border"}),e.jsx("span",{children:t.label})]},t.id)})})]})]}),e.jsxs(y,{onClick:We,disabled:H,children:[e.jsx(Ze,{className:"mr-2 h-4 w-4"}),s(H?"common.actions.loading":"logs.actions.export")]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:s("logs.summary.total",{value:D.toLocaleString()})}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>k.refetch(),disabled:k.isFetching,children:[e.jsx(Xe,{className:h("mr-2 h-4 w-4",k.isFetching&&"animate-spin")}),k.isFetching?s("common.actions.refreshing"):s("logs.actions.manualRefresh")]})]})}),e.jsx(Re,{className:"sticky top-20 z-20 border-white/40 bg-card/90 backdrop-blur",children:e.jsxs(De,{className:"pt-4",children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:s("logs.filtersTitle")}),e.jsx(P,{variant:"outline",children:s("logs.summary.total",{value:D.toLocaleString()})}),z.length>0&&e.jsx(P,{variant:"secondary",children:s("common.filters.activeCount",{count:z.length})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("logs.filtersDescription")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[z.length>0&&e.jsx(y,{variant:"ghost",size:"sm",onClick:Y,children:s("common.actions.reset")}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>qe(t=>!t),children:pe?e.jsxs(e.Fragment,{children:[s("common.filters.collapse"),e.jsx(ss,{className:"ml-1 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:[s("common.filters.expand"),e.jsx(ts,{className:"ml-1 h-4 w-4"})]})})]})]}),e.jsx("div",{className:"flex items-center justify-between gap-3",children:e.jsx("div",{className:"flex flex-1 items-center gap-3 overflow-hidden",children:z.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:z.map(t=>e.jsxs(P,{variant:"secondary",role:"button",tabIndex:0,className:"cursor-pointer gap-1 hover:bg-destructive/10 hover:text-destructive",onClick:t.onRemove,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t.onRemove())},children:[t.label,e.jsx(Fe,{className:"h-3 w-3","aria-hidden":"true"})]},t.key))}):e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.filters.allRequests")})})}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:["all","errors","today","anthropic","openai"].map(t=>e.jsx(y,{variant:Ve===t?"default":"outline",size:"sm",className:"rounded-full",onClick:()=>He(t),children:s(`logs.quickViews.${t}`)},t))})]}),pe&&e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-2 xl:grid-cols-4 animate-in fade-in slide-in-from-top-2 duration-200",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:s("logs.filters.provider")}),e.jsxs(Z,{value:c,onValueChange:v,children:[e.jsx(X,{children:e.jsx(ee,{})}),e.jsxs(se,{children:[e.jsx(T,{value:"all",children:s("logs.filters.providerAll")}),ie.map(t=>e.jsx(T,{value:t.id,children:t.label??t.id},t.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:s("logs.filters.endpoint")}),e.jsxs(Z,{value:g,onValueChange:a,children:[e.jsx(X,{children:e.jsx(ee,{})}),e.jsxs(se,{children:[e.jsx(T,{value:"all",children:s("logs.filters.endpointAll")}),e.jsx(T,{value:"anthropic",children:s("logs.filters.endpointAnthropic")}),e.jsx(T,{value:"openai",children:s("logs.filters.endpointOpenAI")}),(Ce=(Te=ne.data)==null?void 0:Te.endpoints)==null?void 0:Ce.map(t=>e.jsx(T,{value:t.id,children:t.label||t.id},t.id))]})]})]}),e.jsx(js,{className:"md:col-span-2",apiKeys:de,selected:w,disabled:ge.isLoading,onChange:re}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:s("logs.filters.modelId")}),e.jsx(me,{value:d,onChange:t=>j(t.target.value),placeholder:s("logs.filters.modelPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:s("logs.filters.status")}),e.jsxs(Z,{value:x,onValueChange:t=>N(t),children:[e.jsx(X,{children:e.jsx(ee,{})}),e.jsxs(se,{children:[e.jsx(T,{value:"all",children:s("logs.filters.statusAll")}),e.jsx(T,{value:"success",children:s("logs.filters.statusSuccess")}),e.jsx(T,{value:"error",children:s("logs.filters.statusError")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:s("logs.filters.startDate")}),e.jsx(me,{type:"date",value:l,onChange:t=>S(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:s("logs.filters.endDate")}),e.jsx(me,{type:"date",value:r,onChange:t=>m(t.target.value)})]})]})]})}),e.jsx(Re,{children:e.jsxs(De,{className:"p-0",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{ref:oe,className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[1200px] text-sm",children:[e.jsx("thead",{className:"border-b bg-muted/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 z-20 bg-muted/95 px-3 py-2 text-left text-xs font-medium backdrop-blur",children:s("logs.table.columns.time")}),b.has("endpoint")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.endpoint")}),b.has("provider")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.provider")}),b.has("requestedModel")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.requestedModel")}),b.has("routedModel")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.routedModel")}),b.has("apiKey")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.apiKey")}),b.has("inputTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.inputTokens")}),b.has("cacheReadTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.cacheReadTokens")}),b.has("cacheCreationTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.cacheCreationTokens")}),b.has("outputTokens")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.outputTokens")}),b.has("latency")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.latency")}),b.has("ttft")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.ttft")}),b.has("tpot")&&e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium",children:s("logs.table.columns.tpot")}),b.has("status")&&e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium",children:s("logs.table.columns.status")}),b.has("error")&&e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium",children:s("logs.table.columns.error")}),e.jsx("th",{className:"sticky right-0 z-20 bg-muted/95 px-3 py-2 text-center text-xs font-medium backdrop-blur",children:s("logs.table.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y",children:k.isPending?Array.from({length:8}).map((t,n)=>e.jsx(os,{columns:we},n)):be.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:we,className:"px-3 py-8 text-center text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 py-4",children:[e.jsx("span",{children:s("logs.table.empty")}),z.length>0&&e.jsx(y,{variant:"outline",size:"sm",onClick:Y,children:s("common.actions.reset")})]})})}):be.map((t,n)=>e.jsx(fs,{record:t,providerLabelMap:J,apiKeyMap:Ne,onSelect:Je,isEven:n%2===0,density:q,visibleColumnSet:b},t.id))})]})}),Ue&&e.jsx("div",{className:"table-scroll-hint"})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-t p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("logs.table.pagination.perPage")}),e.jsxs(Z,{value:u.toString(),onValueChange:t=>F(Number(t)),children:[e.jsx(X,{className:"w-[80px]",children:e.jsx(ee,{})}),e.jsx(se,{children:Me.map(t=>e.jsx(T,{value:t.toString(),children:t},t))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>p(t=>Math.max(t-1,1)),disabled:f<=1,children:s("logs.table.pagination.previous")}),e.jsx("span",{className:"text-sm text-muted-foreground",children:s("logs.table.pagination.pageLabel",{page:E===0?0:f,total:E})}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>p(t=>E===0?t:Math.min(t+1,E)),disabled:E===0||f>=E,children:s("logs.table.pagination.next")})]})]})]})}),e.jsx(gs,{open:Ie,logId:le,onClose:Ye,providerLabelMap:J,apiKeyMap:Ne})]})}function fs({record:s,providerLabelMap:i,apiKeyMap:c,onSelect:v,isEven:g,density:a,visibleColumnSet:d}){const{t:j}=ae(),x=i.get(s.provider)??s.provider,N=s.endpoint||"-",l=!!s.error,S=s.status_code,r=s.client_model??j("logs.table.requestedModelFallback"),m=s.api_key_id!=null?c.get(s.api_key_id):void 0,f=s.api_key_id==null?j("logs.table.apiKeyUnknown"):m!=null&&m.isWildcard?j("apiKeys.wildcard"):m!=null&&m.name?m.name:s.api_key_name?s.api_key_name:j("logs.table.apiKeyUnknown"),p=a==="compact"?"px-3 py-1.5":"px-3 py-2",u=g?"bg-muted/30":"bg-background";return e.jsxs("tr",{className:h("transition-colors",g?"bg-muted/30":"","hover:bg-muted/50"),children:[e.jsx("td",{className:h("sticky left-0 z-10 text-xs",p,u),children:Pe(s.timestamp)}),d.has("endpoint")&&e.jsx("td",{className:h(p,"text-xs"),children:N}),d.has("provider")&&e.jsx("td",{className:h(p,"text-xs"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:x,children:x})}),d.has("requestedModel")&&e.jsx("td",{className:h(p,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:r,children:r})}),d.has("routedModel")&&e.jsx("td",{className:h(p,"text-xs"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:s.model,children:s.model})}),d.has("apiKey")&&e.jsx("td",{className:h(p,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[90px] truncate",title:f,children:f})}),d.has("inputTokens")&&e.jsx("td",{className:h(p,"text-right text-xs tabular-nums"),children:L(s.input_tokens)}),d.has("cacheReadTokens")&&e.jsx("td",{className:h(p,"text-right text-xs tabular-nums"),children:L(s.cache_read_tokens)}),d.has("cacheCreationTokens")&&e.jsx("td",{className:h(p,"text-right text-xs tabular-nums"),children:L(s.cache_creation_tokens)}),d.has("outputTokens")&&e.jsx("td",{className:h(p,"text-right text-xs tabular-nums"),children:L(s.output_tokens)}),d.has("latency")&&e.jsx("td",{className:h(p,"text-right text-xs tabular-nums"),children:C(s.latency_ms,"ms")}),d.has("ttft")&&e.jsx("td",{className:h(p,"text-right text-xs tabular-nums"),children:C(s.ttft_ms,"ms")}),d.has("tpot")&&e.jsx("td",{className:h(p,"text-right text-xs tabular-nums"),children:C(s.tpot_ms,"ms/tk")}),d.has("status")&&e.jsx("td",{className:h(p,"text-center"),children:e.jsx(P,{variant:l?"destructive":"default",className:"text-xs",children:S??(l?500:200)})}),d.has("error")&&e.jsx("td",{className:h(p,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:s.error??"",children:s.error?s.error:"-"})}),e.jsx("td",{className:h("sticky right-0 z-10 text-center",p,u),children:e.jsx(y,{variant:"outline",size:"sm",onClick:()=>v(s.id),children:j("logs.actions.detail")})})]})}function gs({open:s,logId:i,onClose:c,providerLabelMap:v,apiKeyMap:g}){var f,p;const{t:a}=ae(),{pushToast:d}=Ke(),j=o.useRef(null),x=A(["log-detail",i],{url:`/api/logs/${i}`,method:"GET"},{enabled:s&&i!==null,staleTime:3e4});o.useEffect(()=>{x.isError&&x.error&&d({title:a("logs.detail.loadError"),description:x.error.message,variant:"error"})},[x.isError,x.error,d,a]),o.useEffect(()=>{if(!s)return;const u=F=>{F.key==="Escape"&&c()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s,c]),o.useEffect(()=>{s&&j.current&&j.current.focus()},[s,i]);const N=o.useCallback(async(u,F,le)=>{if(!F){d({title:a("logs.detail.copy.empty",{label:u}),variant:"info"});return}try{await is(F),d({title:a(le),variant:"success"})}catch(I){d({title:a("logs.detail.copy.failure"),description:I instanceof Error?I.message:a("logs.detail.copy.failureFallback"),variant:"error"})}},[d,a]);if(!s)return null;const l=x.data,S=l?v.get(l.provider)??l.provider:"",r=l&&l.api_key_id!=null?g.get(l.api_key_id):void 0,m=l?l.status_code??(l.error?500:200):null;return typeof document>"u"?null:as.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-background/80 backdrop-blur-sm animate-in fade-in duration-200",onClick:c}),e.jsxs("aside",{role:"dialog","aria-modal":"true",className:"flex h-full w-full max-w-xl flex-col border-l bg-card shadow-xl animate-in slide-in-from-right duration-300",children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-6 py-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:a("logs.detail.title")}),l&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a("logs.detail.id",{id:l.id})})]}),e.jsxs(y,{ref:j,variant:"outline",size:"sm",onClick:c,children:[e.jsx(Fe,{className:"mr-2 h-4 w-4"}),a("common.actions.close")]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:x.isPending?e.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[e.jsx(Q,{className:"h-5 w-40"}),e.jsx(Q,{className:"h-4 w-full"}),e.jsx(Q,{className:"h-4 w-3/4"}),e.jsx(Q,{className:"h-32 w-full"}),e.jsx(Q,{className:"h-4 w-1/2"})]}):l?e.jsxs("div",{className:"flex flex-col gap-6 px-6 py-5 text-sm",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("logs.detail.infoSection")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-[1.15rem] border border-white/50 bg-background/70 p-3 text-xs shadow-[0_1px_2px_rgba(15,23,42,0.03)]",children:[e.jsx("span",{className:"font-medium",children:a("logs.detail.summary.route",{from:l.client_model??a("logs.detail.info.noRequestedModel"),to:l.model})}),e.jsx("span",{className:"text-muted-foreground",children:a("logs.detail.summary.latency",{value:C(l.latency_ms,a("common.units.ms"))})}),l.ttft_ms!==null&&e.jsxs("span",{className:"text-muted-foreground",children:["TTFT: ",C(l.ttft_ms,a("common.units.ms"))]}),e.jsx(P,{variant:l.error?"destructive":"default",children:m==null?void 0:m.toString()}),e.jsx(P,{variant:"outline",children:l.stream?a("logs.stream.streaming"):a("logs.stream.single")})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsx(M,{label:a("logs.detail.info.latency"),value:C(l.latency_ms,a("common.units.ms"))}),e.jsx(M,{label:a("logs.detail.info.ttft"),value:C(l.ttft_ms,a("common.units.ms"))}),e.jsx(M,{label:a("logs.detail.info.tpot"),value:C(l.tpot_ms,a("common.units.msPerToken"))})]}),e.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.info.time")}),e.jsx("dd",{className:"font-medium",children:Pe(l.timestamp)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.info.sessionId")}),e.jsx("dd",{className:"font-medium",children:l.session_id??"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.info.endpoint")}),e.jsx("dd",{className:"font-medium",children:l.endpoint||"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.info.provider")}),e.jsx("dd",{className:"font-medium",children:S})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.info.requestedModel")}),e.jsx("dd",{className:"font-medium",children:l.client_model??a("logs.detail.info.noRequestedModel")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.info.model")}),e.jsx("dd",{className:"font-medium",children:l.model})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.info.stream")}),e.jsx("dd",{className:"font-medium",children:ps(l.stream)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.info.status")}),e.jsx("dd",{className:"font-medium",children:m})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsx(M,{label:a("logs.detail.info.inputTokens"),value:L(l.input_tokens)}),e.jsx(M,{label:a("logs.detail.info.cacheReadTokens"),value:L(l.cache_read_tokens)}),e.jsx(M,{label:a("logs.detail.info.cacheCreationTokens"),value:L(l.cache_creation_tokens)}),e.jsx(M,{label:a("logs.detail.info.outputTokens"),value:L(l.output_tokens)})]}),e.jsx("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.info.latency")}),e.jsx("dd",{className:"font-medium",children:C(l.latency_ms,a("common.units.ms"))})]})}),l.error&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a("logs.detail.info.error")}),e.jsx("p",{className:"rounded-[1rem] border border-destructive/50 bg-destructive/10 p-3 text-xs text-destructive",children:l.error})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("logs.detail.apiKey.title")}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 text-sm sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.apiKey.name")}),e.jsx("dd",{className:"font-medium",children:l.api_key_id==null&&!l.api_key_name?a("logs.detail.apiKey.missing"):r!=null&&r.isWildcard?a("apiKeys.wildcard"):(r==null?void 0:r.name)??l.api_key_name??a("logs.detail.apiKey.missing")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.apiKey.identifier")}),e.jsx("dd",{className:"font-medium",children:l.api_key_id??a("common.noData")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.apiKey.masked")}),e.jsx("dd",{className:"font-medium",children:r!=null&&r.isWildcard?a("apiKeys.wildcard"):(r==null?void 0:r.maskedKey)??l.api_key_name??a("logs.detail.apiKey.maskedUnavailable")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:a("logs.detail.apiKey.lastUsed")}),e.jsx("dd",{className:"font-medium",children:r!=null&&r.lastUsedAt?new Date(r.lastUsedAt).toLocaleString():a("common.noData")})]})]}),e.jsxs("div",{className:"rounded-[1rem] border border-border/70 bg-background/70 p-3 text-xs",children:[e.jsx("p",{className:"font-medium",children:a("logs.detail.apiKey.rawMasked")}),e.jsx("p",{className:"mt-1 break-all font-mono",children:l.api_key_value_available?l.api_key_value_masked??a("logs.detail.apiKey.rawUnavailable"):a("logs.detail.apiKey.rawUnavailable")}),e.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:a("logs.detail.apiKey.rawMaskedHint")})]})]}),e.jsx("section",{className:"space-y-3",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>{var u;return N(a("logs.detail.payload.request"),(u=l.payload)==null?void 0:u.prompt,"logs.detail.copy.requestSuccess")},children:[a("logs.detail.payload.request")," · ",a("common.actions.copy")]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>{var u;return N(a("logs.detail.payload.response"),(u=l.payload)==null?void 0:u.response,"logs.detail.copy.responseSuccess")},children:[a("logs.detail.payload.response")," · ",a("common.actions.copy")]})]})}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("logs.detail.payload.request")}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>{var u;return N(a("logs.detail.payload.request"),(u=l.payload)==null?void 0:u.prompt,"logs.detail.copy.requestSuccess")},children:a("common.actions.copy")})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap rounded-[1rem] border border-border/70 bg-background/70 p-3 text-xs",children:$e((f=l.payload)==null?void 0:f.prompt,a("logs.detail.payload.emptyRequest"))})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("logs.detail.payload.response")}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>{var u;return N(a("logs.detail.payload.response"),(u=l.payload)==null?void 0:u.response,"logs.detail.copy.responseSuccess")},children:a("common.actions.copy")})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap rounded-[1rem] border border-border/70 bg-background/70 p-3 text-xs",children:$e((p=l.payload)==null?void 0:p.response,a("logs.detail.payload.emptyResponse"))})]})]}):e.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:a("logs.detail.loadError")})})]})]}),document.body)}function M({label:s,value:i}){return e.jsxs("div",{className:"rounded-xl border border-border/70 bg-background/60 px-3 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-2 text-sm font-semibold",children:i})]})}function js({apiKeys:s,selected:i,onChange:c,disabled:v,className:g}){const{t:a}=ae(),[d,j]=o.useState(!1),x=o.useRef(null);o.useEffect(()=>{if(!d)return;const r=m=>{var f;(f=x.current)!=null&&f.contains(m.target)||j(!1)};return window.addEventListener("mousedown",r),()=>window.removeEventListener("mousedown",r)},[d]);const N=o.useMemo(()=>{if(i.length===0)return[];const r=new Map;for(const m of s)r.set(m.id,m);return i.map(m=>{const f=r.get(m);return f?f.isWildcard?a("apiKeys.wildcard"):f.name:null}).filter(m=>!!m)},[s,i,a]),l=i.length===0?a("logs.filters.apiKeyAll"):a("logs.filters.apiKeySelected",{count:i.length}),S=r=>{i.includes(r)?c(i.filter(m=>m!==r)):c([...i,r])};return e.jsxs("div",{className:h("relative space-y-2",g),ref:x,children:[e.jsx(O,{children:a("logs.filters.apiKey")}),e.jsxs("button",{type:"button",onClick:()=>j(r=>!r),disabled:v||s.length===0,title:a("logs.filters.apiKeyHint"),className:h("flex h-11 w-full items-center justify-between rounded-2xl border border-border/80 bg-background/85 px-4 text-sm shadow-[0_1px_2px_rgba(15,23,42,0.03)] ring-offset-background transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",i.length>0&&"border-primary",d&&"ring-2 ring-ring ring-offset-2"),children:[e.jsxs("span",{className:"truncate",children:[l,N.length>0&&e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:N.join(", ")})]}),e.jsx("svg",{className:h("h-4 w-4 opacity-50 transition-transform",d&&"rotate-180"),viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 10.94l3.71-3.71a.75.75 0 111.06 1.06l-4.24 4.25a.75.75 0 01-1.06 0L5.21 8.29a.75.75 0 01.02-1.08z",clipRule:"evenodd"})})]}),d&&e.jsxs("div",{className:"absolute left-0 top-full z-30 mt-2 w-64 rounded-[1.2rem] border border-white/60 bg-popover/95 p-2 shadow-[0_16px_40px_-28px_rgba(15,23,42,0.45)] backdrop-blur",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-background/70 px-3 py-2 text-xs",children:[e.jsx("span",{children:l}),e.jsx("button",{type:"button",onClick:()=>c([]),disabled:i.length===0,className:"text-primary hover:underline disabled:opacity-40",children:a("common.actions.reset")})]}),e.jsxs("div",{className:"max-h-56 overflow-y-auto py-2",children:[s.map(r=>{const m=r.isWildcard?a("apiKeys.wildcard"):r.name,f=i.includes(r.id);return e.jsxs("label",{className:h("flex cursor-pointer items-center gap-2 rounded-xl px-3 py-2 text-sm transition hover:bg-primary/5",f&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-border",checked:f,onChange:()=>S(r.id)}),e.jsx("span",{className:"truncate",children:m})]},r.id)}),s.length===0&&e.jsx("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:a("logs.filters.apiKeyAll")})]})]})]})}export{Os as default};
|