@chenpu17/cc-gw 0.8.14 → 0.8.16

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.
Files changed (60) hide show
  1. package/package.json +5 -5
  2. package/src/web/dist/assets/About-BFdKK7FR.js +1 -0
  3. package/src/web/dist/assets/ApiKeys-C7GJd1XE.js +1 -0
  4. package/src/web/dist/assets/{ConfirmDialog-oYHVEpGJ.js → ConfirmDialog-D7vLTReM.js} +1 -1
  5. package/src/web/dist/assets/Dashboard-BZ61IQTq.js +1 -0
  6. package/src/web/dist/assets/{DialogShell-DcOGCV8m.js → DialogShell-BWia_d99.js} +1 -1
  7. package/src/web/dist/assets/Events-CM2Ddnk5.js +1 -0
  8. package/src/web/dist/assets/Help-DndY95PX.js +4 -0
  9. package/src/web/dist/assets/{Login-Dn8fbfFq.js → Login-CCMGFORE.js} +1 -1
  10. package/src/web/dist/assets/Logs-W9L1HmeW.js +1 -0
  11. package/src/web/dist/assets/ModelManagement-Dx1W3OOm.js +1 -0
  12. package/src/web/dist/assets/{PageSection-CuZMzA0E.js → PageSection-DVs3faWw.js} +1 -1
  13. package/src/web/dist/assets/{PageState-B03H5AV0.js → PageState-Dvjip2P-.js} +1 -1
  14. package/src/web/dist/assets/PageToolbar-BxRZF-QJ.js +1 -0
  15. package/src/web/dist/assets/Profiler-DAhd7InO.js +1 -0
  16. package/src/web/dist/assets/RoutingManagement-DTi8Xa_u.js +1 -0
  17. package/src/web/dist/assets/Settings-CjF3nCh7.js +1 -0
  18. package/src/web/dist/assets/{Skeleton-i1PjWApN.js → Skeleton-DHQ8ApGX.js} +1 -1
  19. package/src/web/dist/assets/app-DkubSF6m.js +61 -0
  20. package/src/web/dist/assets/{card-ChFVaqLf.js → card-Bx5Pg_wP.js} +1 -1
  21. package/src/web/dist/assets/{charts-core-DzWzxST6.js → charts-core-CK8TVJro.js} +1 -1
  22. package/src/web/dist/assets/{charts-engine-Ds7lwC51.js → charts-engine-CWjgwbj5.js} +1 -1
  23. package/src/web/dist/assets/{charts-react-D0nWbUCA.js → charts-react-CmmN-08P.js} +1 -1
  24. package/src/web/dist/assets/{gateway-BU3dR2tm.js → gateway-DOu5TM82.js} +1 -1
  25. package/src/web/dist/assets/global-CMwh_4v7.css +1 -0
  26. package/src/web/dist/assets/{global-B-NXh5qD.js → global-D8DuA4wF.js} +1 -1
  27. package/src/web/dist/assets/{i18n-Bl2BcCDG.js → i18n-C8tBby0x.js} +1 -1
  28. package/src/web/dist/assets/{input-DW7jGTgj.js → input-b5NRkUKN.js} +1 -1
  29. package/src/web/dist/assets/{label-Ci1io7XA.js → label-DUoPO5Jo.js} +1 -1
  30. package/src/web/dist/assets/{landing-BMe5-cHU.js → landing-BDpFbgJX.js} +1 -1
  31. package/src/web/dist/assets/package-C-Cj5JIX.js +1 -0
  32. package/src/web/dist/assets/{popover-CQHCVE2z.js → popover-BAGiqp11.js} +1 -1
  33. package/src/web/dist/assets/{query-BbGWgOFk.js → query-QCek5MsK.js} +1 -1
  34. package/src/web/dist/assets/{queryKeys-ucXCzh0P.js → queryKeys-BpeJfcg0.js} +1 -1
  35. package/src/web/dist/assets/{radix-mHySgtou.js → radix-CtQBp6Ie.js} +1 -1
  36. package/src/web/dist/assets/{router-CL3rf_uf.js → router-D2Fb4U0L.js} +1 -1
  37. package/src/web/dist/assets/{select-BchX45jJ.js → select-B5oPLG9G.js} +1 -1
  38. package/src/web/dist/assets/{switch-CT24uL_Q.js → switch-BDc99Vsq.js} +1 -1
  39. package/src/web/dist/assets/{table-DdvG93mx.js → table-BG-JeOj-.js} +1 -1
  40. package/src/web/dist/assets/{useApiQuery-tbd4JJaZ.js → useApiQuery-4gJC8RZB.js} +1 -1
  41. package/src/web/dist/assets/{useAppMutation-SONU2xFC.js → useAppMutation-CYWYOsqL.js} +1 -1
  42. package/src/web/dist/assets/useModelManagementState-Vvv4fzeh.js +1 -0
  43. package/src/web/dist/assets/{vendor-z22RpOY0.js → vendor-DdPBfMMb.js} +67 -82
  44. package/src/web/dist/index.html +8 -8
  45. package/src/web/dist/landing.html +5 -5
  46. package/src/web/dist/assets/About-pcECYYVj.js +0 -1
  47. package/src/web/dist/assets/ApiKeys-IDt4ZfLj.js +0 -1
  48. package/src/web/dist/assets/Dashboard-BiCTswfM.js +0 -1
  49. package/src/web/dist/assets/Events-CCYCOF1f.js +0 -1
  50. package/src/web/dist/assets/Help-BW1R1cf1.js +0 -5
  51. package/src/web/dist/assets/Logs-D2FFPpBP.js +0 -1
  52. package/src/web/dist/assets/ModelManagement-BHSUJ4Dg.js +0 -1
  53. package/src/web/dist/assets/PageHeader-DCqHI67a.js +0 -1
  54. package/src/web/dist/assets/Profiler-CEpu2dMu.js +0 -1
  55. package/src/web/dist/assets/RoutingManagement-DahJxjA7.js +0 -1
  56. package/src/web/dist/assets/Settings-Vp7jGxIW.js +0 -1
  57. package/src/web/dist/assets/app-COiQeF3y.js +0 -61
  58. package/src/web/dist/assets/global-B_hBylxt.css +0 -1
  59. package/src/web/dist/assets/package-D5lk1iqk.js +0 -1
  60. package/src/web/dist/assets/useModelManagementState-DcQ0Ac-x.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenpu17/cc-gw",
3
- "version": "0.8.14",
3
+ "version": "0.8.16",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Local-first AI gateway for personal developers and small software teams, with web console and CLI daemon.",
@@ -34,10 +34,10 @@
34
34
  "README.md"
35
35
  ],
36
36
  "optionalDependencies": {
37
- "@chenpu17/cc-gw-darwin-arm64": "0.8.14",
38
- "@chenpu17/cc-gw-linux-arm64": "0.8.14",
39
- "@chenpu17/cc-gw-linux-x64": "0.8.14",
40
- "@chenpu17/cc-gw-win32-x64": "0.8.14"
37
+ "@chenpu17/cc-gw-darwin-arm64": "0.8.16",
38
+ "@chenpu17/cc-gw-linux-arm64": "0.8.16",
39
+ "@chenpu17/cc-gw-linux-x64": "0.8.16",
40
+ "@chenpu17/cc-gw-win32-x64": "0.8.16"
41
41
  },
42
42
  "dependencies": {
43
43
  "colorette": "^2.0.20",
@@ -0,0 +1 @@
1
+ import{r as n,j as e,ap as _,aQ as m,ax as B,Y as R}from"./vendor-DdPBfMMb.js";import{P as q}from"./PageToolbar-BxRZF-QJ.js";import{P as p}from"./PageSection-DVs3faWw.js";import{P as F,a as C}from"./PageState-Dvjip2P-.js";import{u as M}from"./useAppMutation-CYWYOsqL.js";import{u as z}from"./useApiQuery-4gJC8RZB.js";import{u as D,B as x,r as G}from"./app-DkubSF6m.js";import{B as P,q as I}from"./queryKeys-BpeJfcg0.js";import{C as d,a as c}from"./card-Bx5Pg_wP.js";import{p as Q}from"./package-C-Cj5JIX.js";import{u as $}from"./i18n-C8tBby0x.js";import"./global-D8DuA4wF.js";import"./query-QCek5MsK.js";import"./router-D2Fb4U0L.js";import"./radix-CtQBp6Ie.js";function le(){var h,f,g,v,j,N,y,w,k,S;const{t}=$(),{pushToast:r}=D(),[i,A]=n.useState(null),a=z(I.status.gateway(),{url:"/api/status",method:"GET"},{staleTime:6e4});n.useEffect(()=>{a.isError&&a.error&&r({title:t("about.toast.statusError.title"),description:a.error.message,variant:"error"})},[r,a.error,a.isError,t]);const o=M({mutationFn:async()=>G({url:"/api/version/check",method:"GET"}),successToast:s=>s.updateAvailable?{title:t("about.toast.updateAvailable.title",{version:s.latestVersion}),description:t("about.toast.updateAvailable.description",{packageName:s.packageName})}:{title:t("about.toast.upToDate.title",{version:s.currentVersion}),description:t("about.toast.upToDate.description")},errorToast:s=>({title:t("about.toast.updateError.title"),description:s.message}),onSuccess:async s=>{A(s)}}),l=Q.version,u="2026-04-27T04:39:08.284Z",V=n.useMemo(()=>{var s,T;return[{label:t("about.app.labels.name"),value:e.jsx("span",{className:"font-mono",children:"cc-gw"})},{label:t("about.app.labels.version"),value:e.jsxs("span",{"data-visual-volatile":"true",className:"font-mono text-primary",children:["v",l]})},{label:t("about.app.labels.buildTime"),value:e.jsx("span",{"data-visual-volatile":"true",children:u}),hint:t("about.app.hint.buildTime")},{label:t("about.app.labels.runtime"),value:e.jsx("span",{className:"font-mono",children:((s=a.data)==null?void 0:s.runtime)??"rust"})},{label:t("about.app.labels.backendVersion"),value:e.jsx("span",{"data-visual-volatile":"true",className:"font-mono",children:((T=a.data)==null?void 0:T.backendVersion)??"-"})}]},[l,u,(h=a.data)==null?void 0:h.backendVersion,(f=a.data)==null?void 0:f.runtime,t]),b=n.useMemo(()=>{var s;return a.data?[{label:t("about.status.labels.host"),value:a.data.host??"127.0.0.1"},{label:t("about.status.labels.port"),value:e.jsx("span",{"data-visual-volatile":"true",children:a.data.port.toLocaleString()})},{label:t("about.status.labels.providers"),value:a.data.providers.toLocaleString()},{label:t("about.status.labels.active"),value:(a.data.activeRequests??0).toLocaleString(),hint:t("about.status.hint.active")},{label:t("about.status.labels.platform"),value:a.data.platform??"-"},{label:t("about.status.labels.pid"),value:e.jsx("span",{"data-visual-volatile":"true",children:((s=a.data.pid)==null?void 0:s.toLocaleString())??"-"})}]:[]},[a.data,t]);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(q,{info:e.jsxs("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground","data-visual-volatile":"true",children:["v",l]}),status:e.jsx("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:"manual refresh only"}),actions:e.jsxs(x,{onClick:()=>o.mutate(),disabled:o.isPending,size:"sm",children:[e.jsx(_,{className:`mr-2 h-4 w-4${o.isPending?" animate-spin":""}`,"aria-hidden":"true"}),o.isPending?t("about.support.actions.checkingUpdates"):t("about.support.actions.checkUpdates")]})}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(320px,0.85fr)]",children:[e.jsx(d,{className:"overflow-hidden rounded-[1.25rem] border border-white/70 bg-card/95 shadow-[0_20px_50px_-42px_rgba(15,23,42,0.24)]",children:e.jsx(c,{className:"p-5",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-secondary px-3 py-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[e.jsx(m,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Runtime snapshot"]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"metric-number truncate text-4xl font-semibold tracking-tight text-foreground",children:[((g=a.data)==null?void 0:g.host)??"127.0.0.1",":",((v=a.data)==null?void 0:v.port)??"-"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("about.description")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs sm:w-56",children:[e.jsx(L,{label:t("about.status.labels.providers"),value:((N=(j=a.data)==null?void 0:j.providers)==null?void 0:N.toLocaleString())??"-"}),e.jsx(L,{label:t("about.status.labels.active"),value:(((y=a.data)==null?void 0:y.activeRequests)??0).toLocaleString()})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(P,{variant:"outline",children:((w=a.data)==null?void 0:w.runtime)??"rust"}),e.jsx(P,{variant:"outline",children:((k=a.data)==null?void 0:k.platform)??"-"})]})]})})}),e.jsx(d,{className:"overflow-hidden rounded-[1.25rem] border border-white/70 bg-card/95 shadow-[0_20px_50px_-42px_rgba(15,23,42,0.24)]",children:e.jsx(c,{className:"p-5",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Build"}),e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[e.jsxs("p",{"data-visual-volatile":"true",className:"font-mono text-xl font-semibold text-primary",children:["v",l]}),e.jsx("p",{"data-visual-volatile":"true",className:"text-xs text-muted-foreground",children:u})]}),i?e.jsxs("div",{className:"rounded-lg bg-secondary px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:i.updateAvailable?t("about.update.available",{version:i.latestVersion}):t("about.update.current",{version:i.currentVersion})}),e.jsxs("p",{className:"mt-1",children:[t("about.update.channel",{channel:i.channel}),i.publishedAt?` · ${new Date(i.publishedAt).toLocaleString()}`:""]})]}):null,e.jsx("div",{className:"rounded-[0.95rem] bg-secondary/65 px-3.5 py-3 text-sm text-muted-foreground",children:t("about.support.tip")})]})})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(p,{title:t("about.app.title"),description:t("about.app.subtitle"),children:e.jsx(E,{items:V})}),e.jsx(p,{title:t("about.status.title"),description:t("about.status.subtitle"),actions:e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),disabled:a.isFetching,children:[e.jsx(B,{className:J(a.isFetching),"aria-hidden":"true"}),a.isFetching?t("common.actions.refreshing"):t("common.actions.refresh")]}),children:a.isLoading?e.jsx(F,{compact:!0,label:t("about.status.loading")}):a.isError?e.jsx(C,{compact:!0,tone:"danger",icon:e.jsx(m,{className:"h-5 w-5","aria-hidden":"true"}),title:t("common.status.error"),description:((S=a.error)==null?void 0:S.message)??t("common.unknownError"),action:e.jsx(x,{variant:"outline",size:"sm",onClick:()=>void a.refetch(),children:t("common.actions.refresh")})}):b.length>0?e.jsx(E,{items:b}):e.jsx(C,{compact:!0,tone:"primary",icon:e.jsx(m,{className:"h-5 w-5","aria-hidden":"true"}),title:t("about.status.empty"),description:t("common.actions.refresh")})})]}),e.jsx(p,{title:t("about.support.title"),description:e.jsxs("span",{className:"space-y-1",children:[e.jsx("span",{className:"block text-sm font-medium text-primary",children:t("about.support.subtitle")}),e.jsx("span",{children:t("about.support.description")})]}),children:e.jsx(d,{className:"rounded-xl bg-card shadow-[var(--surface-shadow)]",children:e.jsxs(c,{className:"flex flex-col gap-4 pt-5 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-4 rounded-lg bg-secondary p-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-primary/10 text-primary",children:e.jsx(R,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:t("about.support.tip")})]}),e.jsx("code",{className:"inline-flex self-start rounded-lg bg-secondary px-3 py-2 text-xs font-medium",children:"~/.cc-gw/config.json"})]})})})]})}function E({items:t}){return t.length===0?null:e.jsx("dl",{className:"grid gap-3 sm:grid-cols-2",children:t.map(r=>e.jsx(d,{className:"rounded-[1rem] border border-white/70 bg-secondary/45 shadow-none",children:e.jsxs(c,{className:"p-4",children:[e.jsx("dt",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:r.label}),e.jsx("dd",{className:"metric-number mt-2 text-sm font-semibold text-foreground",children:r.value}),r.hint?e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r.hint}):null]})},r.label))})}function L({label:t,value:r}){return e.jsxs("div",{className:"rounded-[0.9rem] bg-secondary/65 px-3 py-2 text-right",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:t}),e.jsx("p",{className:"metric-number mt-1 text-sm font-semibold text-foreground",children:r})]})}function J(t){return`mr-2 h-4 w-4${t?" animate-spin":""}`}export{le as default};
@@ -0,0 +1 @@
1
+ import{r as x,j as e,a1 as os,am as ce,V as Te,aJ as S,aK as de,aL as Ee,aM as cs,aN as Ae,aO as Me,aH as ds}from"./vendor-DdPBfMMb.js";import{r as ps,g as ae,b as te,B as h,u as xs,a as Q,s as U,L as us}from"./app-DkubSF6m.js";import{P as ms}from"./PageToolbar-BxRZF-QJ.js";import{C as hs}from"./ConfirmDialog-D7vLTReM.js";import{D as pe,A as xe,a as ue,b as me,c as qe,d as he,e as ge}from"./DialogShell-BWia_d99.js";import{I as J}from"./input-b5NRkUKN.js";import{L as P}from"./label-DUoPO5Jo.js";import{c as _}from"./global-D8DuA4wF.js";import{u as G}from"./useApiQuery-4gJC8RZB.js";import{q as N,B as C}from"./queryKeys-BpeJfcg0.js";import{u as w}from"./i18n-C8tBby0x.js";import{L as gs}from"./router-D2Fb4U0L.js";import{E as ys,T as bs,a as js,b as ke,c as L,d as fs,e as F}from"./table-BG-JeOj-.js";import{P as We}from"./PageSection-DVs3faWw.js";import{a as oe}from"./PageState-Dvjip2P-.js";import{C as X,a as ye}from"./card-Bx5Pg_wP.js";import{e as vs}from"./charts-core-CK8TVJro.js";import{u as B}from"./useAppMutation-CYWYOsqL.js";import{c as Ks}from"./clipboard-CALi6bTW.js";import"./query-QCek5MsK.js";import"./radix-CtQBp6Ie.js";import"./charts-react-CmmN-08P.js";import"./charts-engine-CWjgwbj5.js";const Le=x.forwardRef(({className:a,...s},l)=>e.jsx("textarea",{className:_("flex min-h-[80px] w-full rounded-xl border border-border bg-card px-3 py-2.5 text-sm text-foreground ring-offset-background placeholder:text-muted-foreground/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:l,...s}));Le.displayName="Textarea";const M={listRequest(){return{url:"/api/keys",method:"GET"}},overviewRequest(a){return{url:"/api/stats/api-keys/overview",method:"GET",params:{days:a}}},usageRequest(a,s=10){return{url:"/api/stats/api-keys/usage",method:"GET",params:{days:a,limit:s}}},customEndpointOptionsRequest(){return{url:"/api/custom-endpoints",method:"GET"}},create:async a=>ae(te.post("/api/keys",a)),update:async(a,s)=>{await ae(te.patch(`/api/keys/${a}`,s))},delete:async a=>{await ae(te.delete(`/api/keys/${a}`))},reveal:async a=>ps({url:`/api/keys/${a}/reveal`,method:"GET"})},Fe=[{value:1,labelKey:"apiKeys.analytics.range.today"},{value:7,labelKey:"apiKeys.analytics.range.week"},{value:30,labelKey:"apiKeys.analytics.range.month"}];function Ns(){var l;const a=[{id:"anthropic",label:"Anthropic"},{id:"openai",label:"OpenAI"}],s=G(N.customEndpoints.all(),M.customEndpointOptionsRequest());return x.useMemo(()=>{var o;const t=(((o=s.data)==null?void 0:o.endpoints)??[]).map(u=>({id:u.id,label:u.label||u.id}));return[...a,...t]},[(l=s.data)==null?void 0:l.endpoints])}function Oe({available:a,hint:s,onChange:l,selected:t}){const{t:o}=w(),u=t.length===0,b=()=>{l([])},f=c=>{if(t.includes(c)){l(t.filter(p=>p!==c));return}l([...t,c])};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-3 text-xs text-muted-foreground",children:s}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-lg border border-border bg-card px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-accent/50",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:b,className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm font-medium",children:o("apiKeys.allEndpoints")})]}),e.jsx("div",{className:"grid max-h-40 gap-1 overflow-y-auto",children:a.map(c=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-lg border border-border bg-card px-3 py-2.5 transition-colors hover:border-primary/20 hover:bg-accent/50",children:[e.jsx("input",{type:"checkbox",checked:!u&&t.includes(c.id),onChange:()=>f(c.id),className:"h-4 w-4 rounded border-input accent-primary"}),e.jsx("span",{className:"text-sm",children:c.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",c.id,")"]})]},c.id))})]})}function ws({availableEndpoints:a,isOpen:s,keyDescription:l,keyName:t,maxConcurrency:o,onDescriptionChange:u,onEndpointsChange:b,onKeyNameChange:f,onMaxConcurrencyChange:c,onOpenChange:p,onSubmit:g,selectedEndpoints:n}){const{t:r}=w();return e.jsx(pe,{open:s,onOpenChange:p,children:e.jsxs(xe,{className:"max-w-2xl",children:[e.jsxs(ue,{children:[e.jsx(me,{children:r("apiKeys.createNew")}),e.jsx(qe,{children:r("apiKeys.createDescription")})]}),e.jsxs(he,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border border-primary/20 bg-accent px-4 py-3 text-xs text-primary",children:r("apiKeys.selectEndpoints")}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-3 text-xs text-primary",children:[e.jsx("p",{className:"font-semibold",children:"Restricted"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Select explicit endpoints before saving."})]}),e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-3 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-200",children:[e.jsx("p",{className:"font-semibold",children:"Unrestricted"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Leave endpoint selection empty for broad access."})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-3 text-xs text-destructive",children:[e.jsx("p",{className:"font-semibold",children:"Wildcard"}),e.jsx("p",{className:"mt-1 opacity-80",children:"Special-case key with the highest blast radius."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(P,{htmlFor:"keyName",children:[r("apiKeys.keyNamePlaceholder")," *"]}),e.jsx(J,{id:"keyName",value:t,onChange:y=>f(y.target.value),placeholder:r("apiKeys.keyNamePlaceholder"),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),g())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"keyDescription",children:r("apiKeys.descriptionLabel")}),e.jsx(Le,{id:"keyDescription",value:l,onChange:y=>u(y.target.value),placeholder:r("apiKeys.keyDescriptionPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:r("apiKeys.allowedEndpoints")}),e.jsx(Oe,{available:a,selected:n,onChange:b,hint:r("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"maxConcurrency",children:r("apiKeys.maxConcurrency")}),e.jsx(J,{id:"maxConcurrency",type:"number",min:"0",value:o,onChange:y=>c(y.target.value),placeholder:r("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(ge,{children:[e.jsx(h,{variant:"outline",onClick:()=>p(!1),children:r("common.actions.cancel")}),e.jsx(h,{onClick:g,children:r("apiKeys.createAction")})]})]})})}function Cs({createdKey:a,onClose:s,onCopy:l}){const{t}=w();return e.jsx(pe,{open:!!a,onOpenChange:o=>{o||s()},children:e.jsxs(xe,{className:"max-w-xl",children:[e.jsx(ue,{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(os,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(me,{children:t("apiKeys.keyCreated")})]})}),e.jsxs(he,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:t("apiKeys.saveKeyWarning")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 font-mono text-sm",children:a==null?void 0:a.key}),a!=null&&a.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:a.description}):null]}),e.jsxs(ge,{children:[e.jsxs(h,{onClick:()=>l((a==null?void 0:a.key)??""),children:[e.jsx(ce,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),t("common.actions.copy")]}),e.jsx(h,{variant:"outline",onClick:s,children:t("common.actions.close")})]})]})})}function Es({apiKey:a,availableEndpoints:s,maxConcurrency:l,onClose:t,onEndpointsChange:o,onMaxConcurrencyChange:u,onSave:b,selectedEndpoints:f}){const{t:c}=w();return e.jsx(pe,{open:!!a,onOpenChange:p=>{p||t()},children:e.jsxs(xe,{className:"max-w-2xl",children:[e.jsxs(ue,{children:[e.jsx(me,{children:c("apiKeys.editEndpoints")}),e.jsx(qe,{children:a==null?void 0:a.name})]}),e.jsxs(he,{className:"space-y-4",children:[!(a!=null&&a.isWildcard)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-200",children:c("apiKeys.allEndpoints")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-xs text-muted-foreground",children:"Empty selection means unrestricted access. Only explicit selections create a restricted key scope."}),e.jsx(Oe,{available:s,selected:f,onChange:o,hint:c("apiKeys.selectEndpoints")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"editMaxConcurrency",children:c("apiKeys.maxConcurrency")}),e.jsx(J,{id:"editMaxConcurrency",type:"number",min:"0",value:l,onChange:p=>u(p.target.value),placeholder:c("apiKeys.maxConcurrencyPlaceholder")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c("apiKeys.maxConcurrencyHelper")})]})]}),e.jsxs(ge,{children:[e.jsx(h,{variant:"outline",onClick:t,children:c("common.actions.cancel")}),e.jsx(h,{onClick:b,children:c("common.save")})]})]})})}function ks({deleteTarget:a,isDeleting:s,onConfirm:l,onOpenChange:t}){const{t:o}=w();return e.jsx(hs,{open:!!a,onOpenChange:t,title:o("apiKeys.deleteDialogTitle"),description:o("apiKeys.confirmDelete"),confirmLabel:a&&s===a.id?o("common.actions.loading"):o("apiKeys.actions.delete"),cancelLabel:o("common.actions.cancel"),loading:a?s===a.id:!1,onConfirm:l,children:a?e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 font-mono text-xs text-foreground",children:a.name}):null})}function Ds(){const{t:a}=w();return e.jsx("div",{className:"rounded-[1.15rem] border border-border/55 bg-card/92 p-3 shadow-[var(--surface-shadow)] sm:p-3.5",children:e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"max-w-md space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-primary/75",children:"Recommended"}),e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:a("apiKeys.quickStart.title")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:a("apiKeys.quickStart.description")})]}),e.jsx("div",{className:"-mx-1 overflow-x-auto pb-1 lg:mx-0 lg:overflow-visible lg:pb-0",children:e.jsxs("div",{className:"flex gap-2 px-1 md:grid md:grid-cols-3 md:px-0 lg:max-w-3xl",children:[e.jsx(ie,{icon:e.jsx(Te,{className:"h-4 w-4","aria-hidden":"true"}),title:a("apiKeys.quickStart.create.title"),description:a("apiKeys.quickStart.create.description")}),e.jsx(ie,{icon:e.jsx(S,{className:"h-4 w-4","aria-hidden":"true"}),title:a("apiKeys.quickStart.restrict.title"),description:a("apiKeys.quickStart.restrict.description")}),e.jsx(ie,{icon:e.jsx(de,{className:"h-4 w-4","aria-hidden":"true"}),title:a("apiKeys.quickStart.wildcard.title"),description:a("apiKeys.quickStart.wildcard.description")})]})})]})})}function Ts({activeKeysValue:a,enabledKeysValue:s,loading:l,onRangeChange:t,rangeDays:o,requestsChartOption:u,totalKeysValue:b,tokensChartOption:f,usageLength:c}){const{t:p}=w();return e.jsx(We,{eyebrow:"Usage",title:p("apiKeys.analytics.title"),description:p("apiKeys.analytics.description",{days:o}),actions:e.jsx("div",{className:"flex w-full items-center gap-1 overflow-x-auto rounded-full bg-secondary p-1 sm:w-auto",children:Fe.map(g=>{const n=o===g.value;return e.jsx("button",{type:"button",onClick:()=>t(g.value),className:_("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",n?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:p(g.labelKey)},g.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(ne,{label:p("apiKeys.analytics.cards.total"),value:b}),e.jsx(ne,{label:p("apiKeys.analytics.cards.enabled"),value:s}),e.jsx(ne,{label:p("apiKeys.analytics.cards.active",{days:o}),value:a})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(De,{title:p("apiKeys.analytics.charts.requests"),loading:l,empty:c===0,emptyText:p("apiKeys.analytics.empty"),option:u}),e.jsx(De,{title:p("apiKeys.analytics.charts.tokens"),loading:l,empty:c===0,emptyText:p("apiKeys.analytics.empty"),option:f})]})]})})}function As({filteredKeys:a,formatDate:s,hasWildcard:l,isDeleting:t,isRevealing:o,keys:u,onCopy:b,onDelete:f,onEditEndpoints:c,onFilterChange:p,onHide:g,onReveal:n,onStatusFilterChange:r,onToggleEnabled:y,restrictedCount:E,revealedKeys:k,search:K,statusFilter:q,unrestrictedCount:v,viewMode:R,wildcardCount:T,onViewModeChange:z,onCreateKey:Y}){const{t:m}=w();return e.jsx(We,{eyebrow:"Inventory",title:m("apiKeys.list.title"),description:l?m("apiKeys.wildcardHint"):void 0,actions:e.jsxs("div",{className:"flex w-full flex-wrap items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-secondary p-1",children:[e.jsxs("button",{type:"button",onClick:()=>z("cards"),className:_("inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium transition-all",R==="cards"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:[e.jsx(Ee,{className:"h-3.5 w-3.5","aria-hidden":"true"}),m("apiKeys.views.cards")]}),e.jsxs("button",{type:"button",onClick:()=>z("compact"),className:_("inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium transition-all",R==="compact"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:[e.jsx(cs,{className:"h-3.5 w-3.5","aria-hidden":"true"}),m("apiKeys.views.compact")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{variant:"outline",children:`${a.length}/${u.length}`}),e.jsx(C,{variant:"outline",children:m("apiKeys.summary.wildcard",{count:T})}),e.jsx(C,{variant:"outline",children:m("apiKeys.summary.restricted",{count:E})})]})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(re,{label:m("apiKeys.list.title"),value:`${a.length}/${u.length}`,helper:m("apiKeys.filters.searchPlaceholder")}),e.jsx(re,{label:m("apiKeys.summary.wildcard",{count:T}),value:String(T),helper:m("apiKeys.wildcardHint")}),e.jsx(re,{label:m("apiKeys.summary.restricted",{count:E}),value:String(E),helper:m("apiKeys.summary.unrestricted",{count:v})})]}),e.jsxs("div",{className:"grid gap-3 rounded-xl bg-secondary p-4 lg:grid-cols-[minmax(0,0.82fr)_auto] xl:grid-cols-[minmax(0,0.95fr)_auto_auto]",children:[e.jsx(J,{value:K,onChange:j=>p(j.target.value),placeholder:m("apiKeys.filters.searchPlaceholder"),className:"lg:max-w-[680px]"}),e.jsx("div",{className:"flex min-w-max items-center gap-1 overflow-x-auto rounded-full bg-background p-1 lg:justify-self-start xl:justify-self-center",children:["all","enabled","disabled"].map(j=>e.jsx("button",{type:"button",onClick:()=>r(j),className:_("inline-flex h-8 shrink-0 items-center rounded-full px-3.5 text-xs font-medium transition-all",q===j?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-primary/5 hover:text-foreground"),children:m(`apiKeys.filters.${j}`)},j))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:col-span-2 xl:col-span-1 xl:justify-self-end",children:[e.jsx(C,{variant:"secondary",children:m("apiKeys.summary.wildcard",{count:T})}),e.jsx(C,{variant:"secondary",children:m("apiKeys.summary.restricted",{count:E})})]})]}),u.length===0?e.jsx(oe,{compact:!0,tone:"primary",className:"rounded-[1.2rem] border-border/30 bg-background/50",icon:e.jsx(Te,{className:"h-5 w-5","aria-hidden":"true"}),title:m("apiKeys.list.emptyTitle"),description:m("apiKeys.list.empty"),action:e.jsx(h,{size:"sm",onClick:Y,children:m("apiKeys.createNew")})}):a.length===0?e.jsx(oe,{compact:!0,tone:"primary",className:"rounded-[1.2rem] border-border/30 bg-background/50",icon:e.jsx(Ee,{className:"h-5 w-5","aria-hidden":"true"}),title:m("apiKeys.list.emptyFilteredTitle"),description:m("apiKeys.list.emptyFiltered"),action:e.jsx(h,{variant:"outline",size:"sm",onClick:()=>{p(""),r("all")},children:m("common.actions.reset")})}):R==="compact"?e.jsx(Ms,{filteredKeys:a,formatDate:s,isDeleting:t,isRevealing:o,onCopy:b,onDelete:f,onEditEndpoints:c,onHide:g,onReveal:n,onToggleEnabled:y,revealedKeys:k}):e.jsx("div",{className:"grid gap-4",children:a.map(j=>e.jsx(qs,{formatDate:s,isDeleting:t===j.id,isRevealing:o===j.id,keySummary:j,onCopy:b,onDelete:f,onEditEndpoints:c,onHide:g,onReveal:n,onToggleEnabled:y,revealedValue:k.get(j.id)},j.id))})]})})}function Ms({filteredKeys:a,formatDate:s,isDeleting:l,isRevealing:t,onCopy:o,onDelete:u,onEditEndpoints:b,onHide:f,onReveal:c,onToggleEnabled:p,revealedKeys:g}){const{t:n}=w();return e.jsx(X,{className:"overflow-hidden border border-border/65 bg-card/96 shadow-[0_18px_42px_rgba(15,23,42,0.06)] ring-1 ring-white/70",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(bs,{className:"min-w-[980px]",children:[e.jsx(js,{children:e.jsxs(ke,{className:"bg-secondary/45 hover:bg-secondary/45",children:[e.jsx(L,{children:n("apiKeys.table.name")}),e.jsx(L,{children:n("apiKeys.table.access")}),e.jsx(L,{className:"text-right",children:n("apiKeys.requestCount")}),e.jsx(L,{className:"text-right",children:n("apiKeys.totalTokens")}),e.jsx(L,{className:"text-right",children:n("apiKeys.maxConcurrency")}),e.jsx(L,{children:n("apiKeys.lastUsed")}),e.jsx(L,{className:"w-[132px] text-right",children:n("apiKeys.table.actions")})]})}),e.jsx(fs,{children:a.map(r=>{var K,q,v;const y=g.get(r.id),E=(r.totalInputTokens+r.totalOutputTokens).toLocaleString(),k=r.isWildcard?n("apiKeys.wildcard"):(((K=r.allowedEndpoints)==null?void 0:K.length)??0)>0?(q=r.allowedEndpoints)==null?void 0:q.join(", "):n("apiKeys.allEndpoints");return e.jsxs(ke,{children:[e.jsx(F,{className:"py-3",children:e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-foreground",children:r.name}),r.isWildcard?e.jsx(C,{variant:"secondary",className:"text-[11px]",children:n("apiKeys.wildcard")}):null,e.jsx(C,{variant:r.enabled?"default":"outline",className:"text-[11px]",children:r.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")})]}),r.isWildcard?null:e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("code",{className:"max-w-[220px] truncate rounded-md bg-secondary px-2 py-1 font-mono text-xs",children:y??r.maskedKey??"********"}),y?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>o(y),"aria-label":n("common.actions.copy"),children:e.jsx(ce,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>f(r.id),"aria-label":n("apiKeys.actions.hide"),children:e.jsx(de,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):e.jsx(h,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c(r.id),disabled:t===r.id,"aria-label":n("apiKeys.actions.reveal"),children:t===r.id?e.jsx("div",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Ae,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})}),e.jsx(F,{className:"py-3",children:e.jsxs("div",{className:"max-w-[180px]",children:[e.jsx("div",{className:"truncate text-sm text-foreground",title:k,children:k}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r.isWildcard?n("apiKeys.table.accessWildcard"):(((v=r.allowedEndpoints)==null?void 0:v.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.table.accessOpen")})]})}),e.jsx(F,{className:"py-3 text-right font-medium",children:r.requestCount.toLocaleString()}),e.jsx(F,{className:"py-3 text-right font-medium",children:E}),e.jsx(F,{className:"py-3 text-right font-medium",children:r.maxConcurrency?String(r.maxConcurrency):"—"}),e.jsxs(F,{className:"py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:s(r.lastUsedAt)}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s(r.createdAt)})]}),e.jsx(F,{className:"py-3",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(h,{variant:"outline",size:"icon",onClick:()=>b(r),className:"h-8 w-8","aria-label":r.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints"),title:r.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints"),children:e.jsx(S,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx(h,{variant:r.enabled?"outline":"default",size:"sm",onClick:()=>p(r.id,r.enabled),className:"h-8 px-2.5 text-xs",children:r.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),r.isWildcard?null:e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>u(r),disabled:l===r.id,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(Me,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})})]},r.id)})})]})})})}function ie({description:a,icon:s,title:l}){return e.jsxs("div",{className:"w-[220px] shrink-0 rounded-[1rem] border border-border/45 bg-secondary/72 p-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.6)] dark:border-white/10 dark:bg-slate-900/[0.52] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04)] md:w-auto",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-[0.8rem] bg-background/85 text-primary dark:bg-slate-950/[0.62] sm:h-8 sm:w-8 sm:rounded-[0.85rem]",children:s}),e.jsx("p",{className:"mt-2 text-[12px] font-semibold leading-5 text-foreground sm:mt-2.5 sm:text-[13px]",children:l}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-4.5 text-muted-foreground sm:text-xs sm:leading-5",children:a})]})}function qs({formatDate:a,isDeleting:s,isRevealing:l,keySummary:t,onCopy:o,onDelete:u,onEditEndpoints:b,onHide:f,onReveal:c,onToggleEnabled:p,revealedValue:g}){var y,E,k;const{t:n}=w(),r=(t.totalInputTokens+t.totalOutputTokens).toLocaleString();return e.jsx(X,{"data-testid":"api-key-card",className:"overflow-hidden border border-border/65 bg-card/96 shadow-[0_18px_42px_rgba(15,23,42,0.06)] ring-1 ring-white/70",children:e.jsx(ye,{className:"space-y-4 pt-4",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold",children:t.name}),t.isWildcard?e.jsx(C,{variant:"secondary",children:n("apiKeys.wildcard")}):null,e.jsx(C,{variant:t.enabled?"default":"outline",children:t.enabled?n("apiKeys.status.enabled"):n("apiKeys.status.disabled")}),t.isWildcard?null:e.jsx(C,{variant:"outline",className:"text-xs",children:(((y=t.allowedEndpoints)==null?void 0:y.length)??0)>0?n("apiKeys.endpointRestricted"):n("apiKeys.allEndpoints")}),!t.isWildcard&&t.allowedEndpoints&&t.allowedEndpoints.length>0?t.allowedEndpoints.map(K=>e.jsx(C,{variant:"outline",className:"text-xs",children:K},K)):t.isWildcard?null:e.jsx(C,{variant:"secondary",className:"text-xs opacity-60",children:n("apiKeys.allEndpoints")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx(le,{label:n("apiKeys.requestCount"),value:t.requestCount.toLocaleString()}),e.jsx(le,{label:n("apiKeys.totalTokens"),value:r}),e.jsx(le,{label:n("apiKeys.maxConcurrency"),value:t.maxConcurrency?String(t.maxConcurrency):n("apiKeys.maxConcurrencyPlaceholder")})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("code",{className:"block max-w-full break-all rounded-lg bg-secondary px-3 py-1.5 font-mono text-sm",children:t.isWildcard?n("apiKeys.wildcard"):g??t.maskedKey??"********"}),t.isWildcard?null:e.jsx("div",{className:"flex items-center gap-1 self-start",children:g?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(g),"aria-label":n("common.actions.copy"),title:n("common.actions.copy"),children:e.jsx(ce,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>f(t.id),"aria-label":n("apiKeys.actions.hide"),title:n("apiKeys.actions.hide"),children:e.jsx(de,{className:"h-4 w-4","aria-hidden":"true"})})]}):e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>c(t.id),disabled:l,"aria-label":n("apiKeys.actions.reveal"),title:n("apiKeys.actions.reveal"),children:l?e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent"}):e.jsx(Ae,{className:"h-4 w-4","aria-hidden":"true"})})})]}),t.isWildcard?e.jsx("p",{className:"text-sm text-muted-foreground",children:n("apiKeys.wildcardHint")}):t.description?e.jsx("p",{className:"whitespace-pre-wrap text-sm text-muted-foreground",children:t.description}):null,t.isWildcard?null:e.jsx("div",{className:"rounded-lg bg-secondary px-3 py-2 text-xs text-muted-foreground",children:(((E=t.allowedEndpoints)==null?void 0:E.length)??0)>0?`${n("apiKeys.allowedEndpoints")}: ${(k=t.allowedEndpoints)==null?void 0:k.join(", ")}`:n("apiKeys.allEndpoints")}),e.jsxs("div",{className:"grid gap-3 text-sm sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n("apiKeys.created")}),e.jsx("p",{className:"font-medium",children:a(t.createdAt)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n("apiKeys.lastUsed")}),e.jsx("p",{className:"font-medium",children:a(t.lastUsedAt)})]})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:flex lg:flex-wrap lg:justify-end",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>b(t),className:"w-full lg:w-auto",children:[e.jsx(S,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),t.isWildcard?n("apiKeys.maxConcurrency"):n("apiKeys.editEndpoints")]}),e.jsx(h,{variant:t.enabled?"outline":"default",size:"sm",onClick:()=>p(t.id,t.enabled),className:"w-full lg:w-auto",children:t.enabled?n("apiKeys.actions.disable"):n("apiKeys.actions.enable")}),t.isWildcard?null:e.jsx(h,{variant:"ghost",size:"icon",className:"h-9 w-full text-destructive hover:bg-destructive/10 hover:text-destructive sm:w-9",onClick:()=>u(t),disabled:s,"aria-label":n("apiKeys.actions.delete"),children:e.jsx(Me,{className:"h-4 w-4","aria-hidden":"true"})})]})]})})})}function ne({label:a,value:s}){return e.jsx(X,{className:"border border-border/70 bg-secondary/70 shadow-none ring-1 ring-white/70",children:e.jsxs(ye,{className:"pt-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"metric-number mt-2 text-3xl font-semibold text-foreground",children:s})]})})}function re({helper:a,label:s,value:l}){return e.jsxs("div",{className:"rounded-xl bg-card px-4 py-3 shadow-[var(--surface-shadow)]",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:s}),e.jsx("p",{className:"metric-number mt-2 text-xl font-semibold text-foreground",children:l}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a})]})}function le({label:a,value:s}){return e.jsxs("div",{className:"rounded-lg bg-secondary px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"mt-1 truncate text-sm font-medium",children:s})]})}function De({empty:a,emptyText:s,loading:l,option:t,title:o}){const{t:u}=w();return e.jsx(X,{children:e.jsxs(ye,{className:"space-y-4 pt-4",children:[e.jsx("h3",{className:"text-base font-semibold",children:o}),l?e.jsx("div",{className:"flex h-[280px] items-center justify-center",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:u("common.loadingShort")})}):a?e.jsx(oe,{compact:!0,className:"min-h-[280px] rounded-[1.1rem] border-border/30 bg-background/50",icon:e.jsx(S,{className:"h-5 w-5","aria-hidden":"true"}),title:s,description:u("apiKeys.analytics.emptyHint"),action:e.jsx(h,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(gs,{to:"/logs",children:u("apiKeys.analytics.actions.logs")})})}):e.jsx(ys,{echarts:vs,option:t,style:{height:280},notMerge:!0,lazyUpdate:!0})]})})}function Ws(){const{t:a}=w(),{pushToast:s}=xs(),[l,t]=x.useState(!1),[o,u]=x.useState(""),[b,f]=x.useState(""),[c,p]=x.useState([]),[g,n]=x.useState(""),[r,y]=x.useState(null),[E,k]=x.useState(null),[K,q]=x.useState(null),[v,R]=Q(U.apiKeys.rangeDays,7,{serialize:i=>String(i),deserialize:i=>{const d=Number(i);return Fe.some(D=>D.value===d)?d:7}}),[T,z]=x.useState(new Map),[Y,m]=x.useState(null),[j,Z]=x.useState(null),[I,be]=x.useState([]),[H,je]=x.useState(""),[ee,Re]=Q(U.apiKeys.search,""),[V,ze]=Q(U.apiKeys.statusFilter,"all",{serialize:i=>i,deserialize:i=>i==="enabled"||i==="disabled"?i:"all"}),[Pe,_e]=Q(U.apiKeys.viewMode,"compact",{serialize:i=>i,deserialize:i=>i==="cards"?"cards":"compact"}),Ie=Ns(),fe=G(N.apiKeys.all(),M.listRequest()),He=G(N.apiKeys.overview(v),M.overviewRequest(v)),ve=G(N.apiKeys.usage(v),M.usageRequest(v)),Ke=B({mutationFn:M.create,invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(v),N.apiKeys.usage(v)],successToast:()=>({title:a("apiKeys.toast.keyCreated")}),errorToast:i=>({title:a("apiKeys.toast.createFailure",{message:i.message})})}),$=B({mutationFn:({id:i,...d})=>M.update(i,d),invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(v),N.apiKeys.usage(v)],successToast:()=>({title:a("apiKeys.toast.keyUpdated")}),errorToast:i=>({title:a("apiKeys.toast.updateFailure",{message:i.message})})}),Ne=B({mutationFn:({id:i})=>M.delete(i),invalidateKeys:[N.apiKeys.all(),N.apiKeys.overview(v),N.apiKeys.usage(v)],successToast:()=>({title:a("apiKeys.toast.keyDeleted")}),errorToast:i=>({title:a("apiKeys.toast.deleteFailure",{message:i.message})})}),we=B({mutationFn:({id:i})=>M.reveal(i),errorToast:i=>({title:a("apiKeys.toast.revealFailure"),description:i.message})}),W=fe.data??[],O=He.data,A=ve.data??[],Ve=W.some(i=>i.isWildcard),$e=W.filter(i=>i.isWildcard).length,Qe=W.filter(i=>{var d;return!i.isWildcard&&(((d=i.allowedEndpoints)==null?void 0:d.length)??0)>0}).length,Ue=W.filter(i=>{var d;return!i.isWildcard&&(((d=i.allowedEndpoints)==null?void 0:d.length)??0)===0}).length,Be=O?O.totalKeys.toLocaleString():"-",Ge=O?O.enabledKeys.toLocaleString():"-",Je=O?O.activeKeys.toLocaleString():"-",Se=x.useMemo(()=>W.filter(i=>{if(!(V==="all"||(V==="enabled"?i.enabled:!i.enabled)))return!1;const D=ee.trim().toLowerCase();return D?[i.name,i.description??"",i.maskedKey??"",...i.allowedEndpoints??[]].join(" ").toLowerCase().includes(D):!0}),[W,ee,V]),Xe=x.useMemo(()=>{const i=A.map(d=>d.apiKeyName??a("apiKeys.analytics.unknownKey"));return{tooltip:{trigger:"axis"},grid:{left:60,right:20,top:40,bottom:40},xAxis:{type:"category",data:i,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.requestsSeries"),type:"bar",data:A.map(d=>d.requests),itemStyle:{color:"hsl(var(--primary))"}}]}},[a,A]),Ye=x.useMemo(()=>{const i=A.map(d=>d.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:i,axisLabel:{interval:0,rotate:20}},yAxis:{type:"value"},series:[{name:a("apiKeys.analytics.tokens.input"),type:"bar",stack:"tokens",itemStyle:{color:"#22c55e"},data:A.map(d=>d.inputTokens)},{name:a("apiKeys.analytics.tokens.output"),type:"bar",stack:"tokens",itemStyle:{color:"#0ea5e9"},data:A.map(d=>d.outputTokens)}]}},[a,A]),Ce=x.useCallback(()=>{u(""),f(""),p([]),n("")},[]),se=x.useCallback(i=>{t(i),i||Ce()},[Ce]),Ze=x.useCallback(async()=>{if(!o.trim()){s({title:a("apiKeys.errors.nameRequired"),variant:"error"});return}try{const i=await Ke.mutateAsync({name:o.trim(),description:b.trim()||void 0,allowedEndpoints:c.length>0?c:void 0,maxConcurrency:g?Number(g):null});y(i),se(!1)}catch{}},[Ke,se,b,c,g,o,s,a]),es=x.useCallback(async(i,d)=>{try{await $.mutateAsync({id:i,enabled:!d})}catch{}},[$]),ss=x.useCallback(async()=>{if(K){k(K.id);try{await Ne.mutateAsync({id:K.id}),q(null)}catch{}finally{k(null)}}},[K,Ne]),as=x.useCallback(async i=>{if(!T.has(i)){m(i);try{const d=await we.mutateAsync({id:i});z(D=>new Map(D).set(i,d.key))}catch{}finally{m(null)}}},[we,T]),ts=x.useCallback(i=>{z(d=>{const D=new Map(d);return D.delete(i),D})},[]),is=x.useCallback(async i=>{try{await Ks(i),s({title:a("apiKeys.toast.keyCopied"),variant:"success"})}catch(d){s({title:a("apiKeys.toast.copyFailure"),description:d instanceof Error?d.message:a("common.unknownError"),variant:"error"})}},[s,a]),ns=x.useCallback(i=>{Z(i),be(i.allowedEndpoints??[]),je(i.maxConcurrency?String(i.maxConcurrency):"")},[]),rs=x.useCallback(async()=>{if(j)try{await $.mutateAsync({id:j.id,...j.isWildcard?{}:{allowedEndpoints:I.length>0?I:null},maxConcurrency:H?Number(H):null}),Z(null)}catch{}},[j,I,H,$]),ls=x.useCallback(i=>i?new Date(i).toLocaleString():a("common.noData"),[a]);return{activeKeysValue:Je,availableEndpoints:Ie,deleteTarget:K,editEndpointsKey:j,editEndpointsSelection:I,editMaxConcurrency:H,enabledKeysValue:Ge,filteredKeys:Se,formatDate:ls,handleCopyKey:is,handleCreateDialogChange:se,handleCreateKey:Ze,handleDeleteKey:ss,handleHideKey:ts,handleOpenEditEndpoints:ns,handleRevealKey:as,handleSaveEndpoints:rs,handleToggleEnabled:es,hasWildcard:Ve,isCreateDialogOpen:l,isDeleting:E,isRevealing:Y,keys:W,keysQuery:fe,newKeyDescription:b,newKeyEndpoints:c,newKeyMaxConcurrency:g,newKeyName:o,newlyCreatedKey:r,rangeDays:v,requestsChartOption:Xe,restrictedCount:Qe,revealedKeys:T,search:ee,setDeleteTarget:q,setEditEndpointsKey:Z,setEditEndpointsSelection:be,setEditMaxConcurrency:je,setNewKeyDescription:f,setNewKeyEndpoints:p,setNewKeyMaxConcurrency:n,setNewKeyName:u,setNewlyCreatedKey:y,setRangeDays:R,setSearch:Re,setStatusFilter:ze,statusFilter:V,tokensChartOption:Ye,totalKeysValue:Be,unrestrictedCount:Ue,usage:A,usageQuery:ve,viewMode:Pe,wildcardCount:$e,setViewMode:_e}}function ta(){const{t:a}=w(),s=Ws(),l=a("apiKeys.summary.totalCount",{count:s.keys.length});return s.keysQuery.isLoading?e.jsx(us,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ms,{info:l?e.jsx("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:l}):null,status:e.jsxs("span",{className:"text-xs text-muted-foreground",children:[a("apiKeys.summary.wildcard",{count:s.wildcardCount})," / ",a("apiKeys.summary.restricted",{count:s.restrictedCount})," / ",a("apiKeys.summary.unrestricted",{count:s.unrestrictedCount})]}),actions:e.jsxs(h,{size:"sm",onClick:()=>s.handleCreateDialogChange(!0),children:[e.jsx(ds,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),a("apiKeys.createNew")]})}),e.jsx(Ds,{}),e.jsx(Ts,{activeKeysValue:s.activeKeysValue,enabledKeysValue:s.enabledKeysValue,loading:s.usageQuery.isLoading,onRangeChange:s.setRangeDays,rangeDays:s.rangeDays,requestsChartOption:s.requestsChartOption,totalKeysValue:s.totalKeysValue,tokensChartOption:s.tokensChartOption,usageLength:s.usage.length}),e.jsx(As,{filteredKeys:s.filteredKeys,formatDate:s.formatDate,hasWildcard:s.hasWildcard,isDeleting:s.isDeleting,isRevealing:s.isRevealing,keys:s.keys,onCopy:t=>void s.handleCopyKey(t),onDelete:s.setDeleteTarget,onEditEndpoints:s.handleOpenEditEndpoints,onFilterChange:s.setSearch,onHide:s.handleHideKey,onReveal:t=>void s.handleRevealKey(t),onStatusFilterChange:s.setStatusFilter,onToggleEnabled:(t,o)=>void s.handleToggleEnabled(t,o),restrictedCount:s.restrictedCount,revealedKeys:s.revealedKeys,search:s.search,statusFilter:s.statusFilter,unrestrictedCount:s.unrestrictedCount,viewMode:s.viewMode,wildcardCount:s.wildcardCount,onViewModeChange:s.setViewMode,onCreateKey:()=>s.handleCreateDialogChange(!0)}),e.jsx(ws,{availableEndpoints:s.availableEndpoints,isOpen:s.isCreateDialogOpen,keyDescription:s.newKeyDescription,keyName:s.newKeyName,maxConcurrency:s.newKeyMaxConcurrency,onDescriptionChange:s.setNewKeyDescription,onEndpointsChange:s.setNewKeyEndpoints,onKeyNameChange:s.setNewKeyName,onMaxConcurrencyChange:s.setNewKeyMaxConcurrency,onOpenChange:s.handleCreateDialogChange,onSubmit:()=>void s.handleCreateKey(),selectedEndpoints:s.newKeyEndpoints}),e.jsx(Cs,{createdKey:s.newlyCreatedKey,onClose:()=>s.setNewlyCreatedKey(null),onCopy:t=>void s.handleCopyKey(t)}),e.jsx(Es,{apiKey:s.editEndpointsKey,availableEndpoints:s.availableEndpoints,maxConcurrency:s.editMaxConcurrency,onClose:()=>s.setEditEndpointsKey(null),onEndpointsChange:s.setEditEndpointsSelection,onMaxConcurrencyChange:s.setEditMaxConcurrency,onSave:()=>void s.handleSaveEndpoints(),selectedEndpoints:s.editEndpointsSelection}),e.jsx(ks,{deleteTarget:s.deleteTarget,isDeleting:s.isDeleting,onConfirm:()=>void s.handleDeleteKey(),onOpenChange:t=>{!t&&s.isDeleting===null&&s.setDeleteTarget(null)}})]})}export{ta as default};
@@ -1 +1 @@
1
- import{j as s}from"./vendor-z22RpOY0.js";import{D as m,A as p,a as j,b as u,c as D,d as f,e as g}from"./DialogShell-DcOGCV8m.js";import{B as o}from"./app-COiQeF3y.js";function C({open:r,onOpenChange:a,title:t,description:i,confirmLabel:n,cancelLabel:d,onConfirm:c,loading:e=!1,confirmVariant:x="destructive",children:l}){return s.jsx(m,{open:r,onOpenChange:a,children:s.jsxs(p,{className:"max-w-md",children:[s.jsxs(j,{children:[s.jsx(u,{children:t}),i?s.jsx(D,{children:i}):null]}),s.jsx(f,{className:"space-y-4",children:l?s.jsx("div",{className:"text-sm text-muted-foreground",children:l}):null}),s.jsxs(g,{children:[s.jsx(o,{variant:"outline",onClick:()=>a(!1),disabled:e,children:d}),s.jsx(o,{variant:x,onClick:()=>void c(),disabled:e,children:n})]})]})})}export{C};
1
+ import{j as s}from"./vendor-DdPBfMMb.js";import{D as m,A as p,a as j,b as u,c as D,d as f,e as g}from"./DialogShell-BWia_d99.js";import{B as o}from"./app-DkubSF6m.js";function C({open:r,onOpenChange:a,title:t,description:i,confirmLabel:n,cancelLabel:d,onConfirm:c,loading:e=!1,confirmVariant:x="destructive",children:l}){return s.jsx(m,{open:r,onOpenChange:a,children:s.jsxs(p,{className:"max-w-md",children:[s.jsxs(j,{children:[s.jsx(u,{children:t}),i?s.jsx(D,{children:i}):null]}),s.jsx(f,{className:"space-y-4",children:l?s.jsx("div",{className:"text-sm text-muted-foreground",children:l}):null}),s.jsxs(g,{children:[s.jsx(o,{variant:"outline",onClick:()=>a(!1),disabled:e,children:d}),s.jsx(o,{variant:x,onClick:()=>void c(),disabled:e,children:n})]})]})})}export{C};
@@ -0,0 +1 @@
1
+ import{j as e,ap as Ce,af as Re,W as Q,ak as _e,aq as Pe,ar as qe,O as H,as as Me,at as Ae,au as Be,av as ne,aw as De,r as u,ax as Fe,U as Oe}from"./vendor-DdPBfMMb.js";import{P as $e}from"./PageToolbar-BxRZF-QJ.js";import{P as V,a as G}from"./PageState-Dvjip2P-.js";import{B as D,u as Ge,a as ze,b as Qe,t as Ue,s as He}from"./app-DkubSF6m.js";import{S as Ve,a as Ke,b as We,c as Ye,d as q}from"./select-B5oPLG9G.js";import{c as C}from"./global-D8DuA4wF.js";import{L as Ze}from"./router-D2Fb4U0L.js";import{T as ie,a as de,b as F,c as j,d as le,e as y,E as Je}from"./table-BG-JeOj-.js";import{P as ce}from"./PageSection-DVs3faWw.js";import{S as Xe,C as et,T as tt}from"./Skeleton-DHQ8ApGX.js";import{B as k,q as I}from"./queryKeys-BpeJfcg0.js";import{C as O,a as $}from"./card-Bx5Pg_wP.js";import{g as ae}from"./utils-DSaa7c6v.js";import{u as w}from"./i18n-C8tBby0x.js";import{e as st}from"./charts-core-CK8TVJro.js";import{u as L}from"./useApiQuery-4gJC8RZB.js";import"./query-QCek5MsK.js";import"./radix-CtQBp6Ie.js";import"./charts-react-CmmN-08P.js";import"./charts-engine-CWjgwbj5.js";const M=15e3,z=6e4,T={requests:"#2563eb",input:"#059669",output:"#ea580c",cacheRead:"#7c3aed",cacheCreation:"#e11d48",latency:"#0891b2"};function R(s,t,a){return s==null?"-":`${s.toLocaleString(void 0,a)} ${t}`}function U(s){if(s==null)return"-";if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s/1024,r=0;for(;a>=1024&&r<t.length-1;)a/=1024,r+=1;return`${a.toFixed(a>=100?0:a>=10?1:2)} ${t[r]}`}function re(s){if(s==null)return"-";const t=s<1?0:s;return t<1024?`${t.toLocaleString(void 0,{maximumFractionDigits:t>=100?0:t>=10?1:2})} B/s`:`${U(t)}/s`}function at(s){return s==null?"-":`${s.toLocaleString(void 0,{maximumFractionDigits:s>=10?0:1})}%`}function rt(){return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"h-20 animate-pulse rounded-xl bg-card shadow-[var(--surface-shadow)]"}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:Array.from({length:12}).map((s,t)=>e.jsx(Xe,{},t))}),e.jsx("div",{className:"grid gap-6 lg:grid-cols-2",children:Array.from({length:4}).map((s,t)=>e.jsx(et,{},t))}),e.jsx("div",{className:"rounded-xl bg-card shadow-[var(--surface-shadow)]",children:e.jsx("table",{className:"w-full",children:e.jsx("tbody",{children:Array.from({length:5}).map((s,t)=>e.jsx(tt,{columns:6},t))})})})]})}function ot({selectedEndpointLabel:s,status:t,todayRequests:a}){const{t:r}=w();return e.jsxs("div",{className:"flex flex-col gap-4 rounded-xl bg-card p-6 shadow-[var(--surface-shadow)] sm:flex-row sm:items-center sm:justify-between","data-testid":"dashboard-overview-panel",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(Ce,{className:"h-5 w-5 text-primary","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:s}),e.jsx(k,{variant:"success",children:r("dashboard.status.listeningLabel")})]}),e.jsxs("p",{className:"mt-0.5 text-sm text-muted-foreground",children:[e.jsxs("span",{"data-testid":"dashboard-runtime-address",children:[(t==null?void 0:t.host)??"0.0.0.0",":",(t==null?void 0:t.port)??"-"]}),e.jsx("span",{className:"mx-2 text-border",children:"·"}),r("dashboard.labels.todayRequests"),": ",a.toLocaleString(),e.jsx("span",{className:"mx-2 text-border",children:"·"}),r("dashboard.labels.providers"),": ",((t==null?void 0:t.providers)??0).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground",children:[e.jsxs("span",{children:[r("dashboard.labels.activeClientAddresses"),": ",e.jsx("strong",{className:"text-foreground",children:((t==null?void 0:t.activeClientAddresses)??0).toLocaleString()})]}),e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{children:[r("dashboard.labels.activeClientSessions"),": ",e.jsx("strong",{className:"text-foreground",children:((t==null?void 0:t.activeClientSessions)??0).toLocaleString()})]})]})]})}function nt({dbSizeDisplay:s,memoryDisplay:t,overview:a,status:r}){const{t:o}=w(),c=[{icon:e.jsx(Re,{className:"h-4 w-4"}),label:o("dashboard.labels.activeRequests"),value:((r==null?void 0:r.activeRequests)??0).toLocaleString(),testId:"dashboard-spotlight-value-active"},{icon:e.jsx(Q,{className:"h-4 w-4"}),label:o("dashboard.labels.requestsPerMinute"),value:((r==null?void 0:r.requestsPerMinute)??0).toLocaleString(),testId:"dashboard-spotlight-value-rpm"},{icon:e.jsx(_e,{className:"h-4 w-4"}),label:o("dashboard.labels.outputTokensPerMinute"),value:((r==null?void 0:r.outputTokensPerMinute)??0).toLocaleString(),testId:"dashboard-spotlight-value-tpm"},{icon:e.jsx(Pe,{className:"h-4 w-4"}),label:o("dashboard.labels.cpu"),value:at(r==null?void 0:r.cpuUsagePercent),testId:"dashboard-spotlight-value-cpu"}],l=[{icon:e.jsx(Q,{className:"h-4 w-4"}),label:o("dashboard.cards.todayRequests"),value:((a==null?void 0:a.today.requests)??0).toLocaleString(),suffix:o("common.units.request")},{icon:e.jsx(qe,{className:"h-4 w-4"}),label:o("dashboard.cards.todayInput"),value:((a==null?void 0:a.today.inputTokens)??0).toLocaleString(),suffix:o("common.units.token")},{icon:e.jsx(H,{className:"h-4 w-4"}),label:o("dashboard.cards.todayOutput"),value:((a==null?void 0:a.today.outputTokens)??0).toLocaleString(),suffix:o("common.units.token")},{icon:e.jsx(Me,{className:"h-4 w-4"}),label:o("dashboard.cards.avgLatency"),value:R((a==null?void 0:a.today.avgLatencyMs)??0,o("common.units.ms"))},{icon:e.jsx(Ae,{className:"h-4 w-4"}),label:o("dashboard.labels.networkIngress"),value:re(r==null?void 0:r.networkIngressBytesPerSecond),testId:"dashboard-spotlight-value-ingress"},{icon:e.jsx(Be,{className:"h-4 w-4"}),label:o("dashboard.labels.networkEgress"),value:re(r==null?void 0:r.networkEgressBytesPerSecond),testId:"dashboard-spotlight-value-egress"},{icon:e.jsx(ne,{className:"h-4 w-4"}),label:o("dashboard.labels.database"),value:s,testId:"dashboard-spotlight-value-database"},{icon:e.jsx(De,{className:"h-4 w-4"}),label:o("dashboard.labels.memory"),value:t,testId:"dashboard-spotlight-value-memory"}];return e.jsxs("div",{className:"space-y-3","data-testid":"dashboard-spotlight-grid",children:[e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-5",children:c.map((n,i)=>e.jsx(oe,{className:i===0?"md:col-span-2 xl:col-span-2":void 0,featured:i===0,icon:n.icon,label:n.label,value:n.value,valueTestId:n.testId},n.label))}),e.jsx("div",{className:"grid gap-2.5 sm:grid-cols-2 lg:grid-cols-4",children:l.map(n=>e.jsx(oe,{compact:!0,icon:n.icon,label:n.label,suffix:n.suffix,value:n.value,valueTestId:n.testId},n.label))})]})}function it({busiestDay:s,fastestTtftModel:t,topModel:a,totalRequestsInRange:r}){const{t:o}=w();return e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.4fr_repeat(3,minmax(0,1fr))]",children:[e.jsx(A,{featured:!0,label:o("dashboard.insights.totalRequests"),value:r.toLocaleString(),hint:o("dashboard.insights.totalRequestsHint")}),e.jsx(A,{label:o("dashboard.insights.busiestDay"),value:s?s.date:"-",hint:s?o("dashboard.insights.busiestDayHint",{value:s.requestCount.toLocaleString()}):o("common.noData")}),e.jsx(A,{label:o("dashboard.insights.topModel"),value:a?`${a.provider}/${a.model}`:"-",hint:a?o("dashboard.insights.topModelHint",{value:a.requests.toLocaleString()}):o("common.noData")}),e.jsx(A,{label:o("dashboard.insights.fastestTtft"),value:t?`${t.provider}/${t.model}`:"-",hint:t?R(t.avgTtftMs,o("common.units.ms")):o("common.noData")})]})}function dt({endpointCount:s,providerCount:t,selectedEndpointLabel:a}){const r=[{title:"先配置 Provider",description:t>0?`当前已检测到 ${t} 个 Provider,可直接继续下一步。`:"先在模型供应商里接入至少 1 个上游模型服务。",href:"/models",cta:"去模型供应商",tone:"from-indigo-100 to-cyan-100"},{title:"确认默认路由入口",description:s>0?`当前已有 ${s} 个自定义端点,可继续检查默认映射是否合理。`:"把一个端点或默认路由配置清楚,后续客户端就能稳定接入。",href:"/routing",cta:"去路由管理",tone:"from-violet-100 to-fuchsia-100"},{title:"发起第一条真实请求",description:"创建 API Key,然后从常用客户端打进来一条请求,让日志、路由和延迟开始有数据。",href:"/api-keys",cta:"去 API 密钥",tone:"from-emerald-100 to-cyan-100"}];return e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.2fr)_minmax(300px,0.8fr)]",children:[e.jsx(O,{className:"overflow-hidden border-white/80 bg-[linear-gradient(135deg,rgba(255,255,255,0.98),hsl(var(--primary)/0.08),rgba(236,253,245,0.8))] shadow-[0_22px_56px_-40px_rgba(15,23,42,0.24)]",children:e.jsxs($,{className:"space-y-5 pt-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"inline-flex items-center rounded-full bg-primary/10 px-3 py-1 text-[11px] font-semibold uppercase tracking-[0.16em] text-primary",children:"Cold Start Guide"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"当前还是冷启动状态,这是正常的"}),e.jsx("p",{className:"mt-1.5 text-sm leading-6 text-muted-foreground",children:"这个仪表盘会在第一条真实请求进来后明显更有价值。现在最适合做的是把 Provider、路由和 API Key 三件事顺次走通。"})]})]}),e.jsx("div",{className:"grid gap-3 lg:grid-cols-3",children:r.map((o,c)=>e.jsxs("div",{className:"rounded-[1.1rem] border border-white/70 bg-card/88 p-4 shadow-[0_16px_40px_-34px_rgba(15,23,42,0.18)]",children:[e.jsxs("div",{className:C("flex h-10 w-10 items-center justify-center rounded-2xl bg-gradient-to-br text-sm font-semibold text-primary",o.tone),children:["0",c+1]}),e.jsx("h4",{className:"mt-3 text-sm font-semibold text-foreground",children:o.title}),e.jsx("p",{className:"mt-1.5 text-xs leading-6 text-muted-foreground",children:o.description}),e.jsx(D,{asChild:!0,variant:"ghost",size:"sm",className:"mt-3 h-8 rounded-full px-0 text-primary hover:bg-transparent hover:text-primary/80",children:e.jsx(Ze,{to:o.href,children:o.cta})})]},o.title))})]})}),e.jsx(O,{className:"border-white/80 bg-card/96 shadow-[0_20px_48px_-40px_rgba(15,23,42,0.24)]",children:e.jsxs($,{className:"space-y-4 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/80",children:"Workspace Snapshot"}),e.jsx("h3",{className:"mt-2 text-base font-semibold text-foreground",children:a}),e.jsx("p",{className:"mt-1 text-xs leading-6 text-muted-foreground",children:"等第一批流量进来后,这里会逐步展示趋势、模型表现和最近请求。"})]}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-3 xl:grid-cols-1",children:[{label:"已配置 Provider",value:String(t)},{label:"自定义端点",value:String(s)},{label:"建议下一步",value:"发起请求"}].map(o=>e.jsxs("div",{className:"rounded-[1rem] bg-secondary/45 px-4 py-3 ring-1 ring-white/70",children:[e.jsx("div",{className:"text-[11px] font-medium text-muted-foreground",children:o.label}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-foreground",children:o.value})]},o.label))}),e.jsx("div",{className:"rounded-[1rem] border border-dashed border-border/45 bg-secondary/35 px-4 py-3",children:e.jsxs("p",{className:"text-xs leading-6 text-muted-foreground",children:["如果你还没确定从哪一步开始,优先去 ",e.jsx("span",{className:"font-medium text-foreground",children:"API 密钥"})," 创建一个客户端专用 key,再从常用工具发起一条最小请求。"]})})]})})]})}function lt({dailyEmpty:s,dailyOption:t,dailyPending:a,models:r,modelRequestsOption:o,modelUsagePending:c,ttftOption:l,tpotOption:n}){const{t:i}=w();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(B,{title:i("dashboard.charts.requestsTitle"),description:i("dashboard.charts.requestsDesc"),loading:a,option:t,empty:s,emptyText:i("dashboard.charts.empty")}),e.jsx(B,{title:i("dashboard.charts.modelTitle"),description:i("dashboard.charts.modelDesc"),loading:c,option:o,empty:!r.length,emptyText:i("dashboard.charts.empty")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(B,{title:i("dashboard.charts.ttftTitle"),description:i("dashboard.charts.ttftDesc"),loading:c,option:l,empty:!r.some(m=>m.avgTtftMs!=null&&m.avgTtftMs>0),emptyText:i("dashboard.charts.ttftEmpty")}),e.jsx(B,{title:i("dashboard.charts.tpotTitle"),description:i("dashboard.charts.tpotDesc"),loading:c,option:n,empty:!r.some(m=>m.avgTpotMs!=null&&m.avgTpotMs>0),emptyText:i("dashboard.charts.tpotEmpty")})]})]})}function ct({models:s,loading:t}){const{t:a}=w();return e.jsx(ce,{title:a("dashboard.modelTable.title"),description:a("dashboard.modelTable.description"),children:t?e.jsx(V,{compact:!0,label:a("common.loadingShort")}):s.length===0?e.jsx(G,{compact:!0,icon:e.jsx(H,{className:"h-5 w-5","aria-hidden":"true"}),title:a("dashboard.modelTable.empty")}):e.jsx("div",{className:"overflow-auto",children:e.jsxs(ie,{children:[e.jsx(de,{children:e.jsxs(F,{children:[e.jsx(j,{children:a("dashboard.modelTable.columns.model")}),e.jsx(j,{className:"text-right",children:a("dashboard.modelTable.columns.requests")}),e.jsx(j,{className:"text-right",children:a("dashboard.modelTable.columns.latency")}),e.jsx(j,{className:"text-right",children:a("dashboard.modelTable.columns.ttft")}),e.jsx(j,{className:"text-right",children:a("dashboard.modelTable.columns.tpot")})]})}),e.jsx(le,{children:s.map(r=>e.jsxs(F,{children:[e.jsx(y,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:r.provider}),e.jsx("span",{className:"text-xs text-muted-foreground",children:r.model})]})}),e.jsx(y,{className:"text-right font-medium",children:r.requests.toLocaleString()}),e.jsx(y,{className:"text-right",children:R(r.avgLatencyMs,a("common.units.ms"))}),e.jsx(y,{className:"text-right",children:R(r.avgTtftMs,a("common.units.ms"))}),e.jsx(y,{className:"text-right",children:R(r.avgTpotMs,a("common.units.msPerToken"),{maximumFractionDigits:2})})]},`${r.provider}/${r.model}`))})]})})})}function mt({records:s,loading:t}){const{t:a}=w(),r=s.map(n=>ae(n,a)),o=r.filter(n=>n.tone==="success").length,c=r.filter(n=>n.tone==="error").length,l=r.filter(n=>n.tone==="pending").length;return e.jsx(ce,{title:a("dashboard.recent.title"),description:a("dashboard.recent.subtitle",{count:5}),actions:s.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(k,{variant:"secondary",children:s.length}),e.jsxs(k,{variant:"success",children:[a("common.status.success"),": ",o]}),e.jsxs(k,{variant:"outline",className:"border-destructive/30 bg-destructive/10 text-destructive",children:[a("common.status.error"),": ",c]}),l>0?e.jsxs(k,{variant:"warning",children:[a("common.status.pending"),": ",l]}):null]}):null,children:t?e.jsx(V,{compact:!0,label:a("dashboard.recent.loading")}):s.length===0?e.jsx(G,{compact:!0,icon:e.jsx(Q,{className:"h-5 w-5","aria-hidden":"true"}),title:a("dashboard.recent.empty")}):e.jsx("div",{className:"overflow-auto",children:e.jsxs(ie,{children:[e.jsx(de,{children:e.jsxs(F,{children:[e.jsx(j,{children:a("dashboard.recent.columns.time")}),e.jsx(j,{children:a("dashboard.recent.columns.endpoint")}),e.jsx(j,{children:a("dashboard.recent.columns.provider")}),e.jsx(j,{children:a("dashboard.recent.columns.route")}),e.jsx(j,{className:"text-right",children:a("dashboard.recent.columns.latency")}),e.jsx(j,{children:a("dashboard.recent.columns.status")})]})}),e.jsx(le,{children:s.map(n=>{const i=ae(n,a);return e.jsxs(F,{children:[e.jsx(y,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium",children:new Date(n.timestamp).toLocaleString()}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["#",n.id]})]})}),e.jsx(y,{children:e.jsx(k,{variant:"outline",className:"text-[11px]",children:n.endpoint==="anthropic"?a("logs.endpointAnthropic"):n.endpoint==="openai"?a("logs.endpointOpenAI"):n.endpoint})}),e.jsx(y,{children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:n.provider}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:n.stream?"stream":"sync"})]})}),e.jsx(y,{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:n.client_model??a("dashboard.recent.routePlaceholder")}),e.jsx("span",{children:"->"}),e.jsx("span",{className:"font-medium text-foreground",children:n.model})]}),n.error?e.jsx("span",{className:"truncate text-destructive",children:n.error}):null]})}),e.jsx(y,{className:"text-right font-medium",children:R(n.latency_ms,a("common.units.ms"))}),e.jsx(y,{children:e.jsx(k,{variant:i.variant,className:"min-w-14 justify-center",children:i.label})})]},n.id)})})]})})})}function oe({className:s,compact:t,featured:a,icon:r,label:o,value:c,suffix:l,valueTestId:n}){return e.jsxs("div",{className:C("group flex flex-col justify-between rounded-[1.15rem] border border-white/70 bg-card/95 shadow-[0_18px_42px_-36px_rgba(15,23,42,0.24)] transition-all hover:-translate-y-0.5 hover:shadow-[0_24px_48px_-38px_rgba(59,130,246,0.2)] dark:border-white/10 dark:bg-slate-950/90 dark:shadow-[0_18px_42px_-36px_rgba(0,0,0,0.72)] dark:hover:shadow-[0_24px_48px_-38px_rgba(59,130,246,0.28)]",a?"bg-[linear-gradient(135deg,hsl(var(--primary)/0.1),rgba(255,255,255,0.95)_46%,rgba(236,253,245,0.74))] p-5 dark:!bg-none dark:!bg-slate-950/90":t?"p-3.5":"p-5",s),children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:C("inline-flex h-7 w-7 items-center justify-center rounded-lg bg-primary/10 text-primary",t&&"h-6 w-6 rounded-md"),children:r}),e.jsx("span",{children:o})]}),e.jsxs("p",{className:C("metric-number mt-3 font-semibold tracking-tight text-foreground",a?"text-3xl":t?"text-lg":"text-2xl"),"data-testid":n,children:[c,l?e.jsx("span",{className:"ml-1 text-sm font-normal text-muted-foreground",children:l}):null]})]})}function A({featured:s,label:t,value:a,hint:r}){return e.jsx(O,{className:s?"overflow-hidden bg-[linear-gradient(135deg,rgba(255,255,255,0.98),hsl(var(--primary)/0.08))] dark:!bg-none dark:!bg-card dark:border-white/10 dark:shadow-[0_18px_42px_-36px_rgba(0,0,0,0.72)]":void 0,children:e.jsxs($,{className:C("pt-4",s&&"pb-4"),children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:t}),e.jsx("p",{className:C("mt-2 line-clamp-1 font-semibold text-foreground",s?"metric-number text-2xl tracking-tight":"text-base"),children:a}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r})]})})}function B({description:s,empty:t,emptyText:a,loading:r,option:o,title:c}){const{t:l}=w();return e.jsx(O,{children:e.jsxs($,{className:"space-y-4 pt-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:c}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground/70",children:s})]}),r?e.jsx(V,{compact:!0,className:"min-h-[220px]",label:l("common.loadingShort")}):t?e.jsx(G,{compact:!0,className:"min-h-[188px] rounded-[1rem] border border-dashed border-border/45 bg-secondary/35",icon:e.jsx(H,{className:"h-5 w-5","aria-hidden":"true"}),title:a??l("dashboard.charts.empty"),description:s}):e.jsx("div",{className:"pt-2",children:e.jsx(Je,{echarts:st,option:o,className:"h-[40vh] min-h-[280px] max-h-[420px]",notMerge:!0,lazyUpdate:!0})})]})})}function ht(){var K,W,Y,Z,J,X,ee,te;const{t:s}=w(),{pushToast:t}=Ge(),[a,r]=ze(He.dashboard.endpointFilter,"all"),[o,c]=u.useState(!1),l=a==="all"?void 0:a,n=L(I.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"},{refetchInterval:z,refetchIntervalInBackground:!0}),i=L(I.stats.overview(a),{url:"/api/stats/overview",method:"GET",params:l?{endpoint:l}:void 0},{refetchInterval:M,refetchIntervalInBackground:!0}),m=L(I.stats.daily(14,a),{url:"/api/stats/daily",method:"GET",params:{days:14,...l?{endpoint:l}:{}}},{refetchInterval:z,refetchIntervalInBackground:!0}),v=L(I.stats.model(7,6,a),{url:"/api/stats/model",method:"GET",params:{days:7,limit:6,...l?{endpoint:l}:{}}},{refetchInterval:z,refetchIntervalInBackground:!0}),g=L(I.status.byEndpoint(a),{url:"/api/status",method:"GET",params:l?{endpoint:l}:void 0},{refetchInterval:M,refetchIntervalInBackground:!0}),x=L(I.db.info(),{url:"/api/db/info",method:"GET"},{refetchInterval:M,refetchIntervalInBackground:!0}),N=L(I.logs.recent(a),{url:"/api/logs",method:"GET",params:{limit:5,...l?{endpoint:l}:{}}},{refetchInterval:M,refetchIntervalInBackground:!0});u.useEffect(()=>{i.isError&&i.error&&t({title:s("dashboard.toast.overviewError"),description:i.error.message,variant:"error"})},[i.error,i.isError,t,s]),u.useEffect(()=>{m.isError&&m.error&&t({title:s("dashboard.toast.dailyError"),description:m.error.message,variant:"error"})},[m.error,m.isError,t,s]),u.useEffect(()=>{v.isError&&v.error&&t({title:s("dashboard.toast.modelError"),description:v.error.message,variant:"error"})},[v.error,v.isError,t,s]),u.useEffect(()=>{g.isError&&g.error&&t({title:s("dashboard.toast.statusError"),description:g.error.message,variant:"error"})},[g.error,g.isError,t,s]),u.useEffect(()=>{x.isError&&x.error&&t({title:s("dashboard.toast.dbError"),description:x.error.message,variant:"error"})},[x.error,x.isError,t,s]),u.useEffect(()=>{N.isError&&N.error&&t({title:s("dashboard.toast.recentError"),description:N.error.message,variant:"error"})},[N.error,N.isError,t,s]);const me=u.useCallback(async()=>{await Promise.all([n.refetch(),i.refetch(),m.refetch(),v.refetch(),g.refetch(),x.refetch(),N.refetch()])},[n,x,m,N,v,i,g]),he=u.useCallback(async()=>{if(!o){c(!0);try{await Qe.post("/api/db/compact"),await x.refetch(),t({title:s("dashboard.toast.compactSuccess.title"),description:s("dashboard.toast.compactSuccess.desc"),variant:"success"})}catch(d){const h=Ue(d);t({title:s("dashboard.toast.compactError.title"),description:h.message,variant:"error"})}finally{c(!1)}}},[o,x,t,s]),pe=i.data,S=m.data??[],p=v.data??[],xe=g.data,E=x.data,ue=((K=N.data)==null?void 0:K.items)??[],ge=a==="all"?s("dashboard.filters.endpointAll"):a==="anthropic"?s("dashboard.filters.endpointAnthropic"):a==="openai"?s("dashboard.filters.endpointOpenAI"):((Z=(Y=(W=n.data)==null?void 0:W.endpoints)==null?void 0:Y.find(d=>d.id===a))==null?void 0:Z.label)||a,be=S.reduce((d,h)=>d+h.requestCount,0),fe=S.reduce((d,h)=>!d||h.requestCount>d.requestCount?h:d,null),je=p[0],ye=p.filter(d=>d.avgTtftMs!=null&&d.avgTtftMs>0).sort((d,h)=>(d.avgTtftMs??Number.POSITIVE_INFINITY)-(h.avgTtftMs??Number.POSITIVE_INFINITY))[0],ve=n.isFetching||i.isFetching||m.isFetching||v.isFetching||g.isFetching||x.isFetching||N.isFetching,Ne=i.isPending||g.isPending||x.isPending,Se=((J=i.error)==null?void 0:J.message)??((X=g.error)==null?void 0:X.message)??((ee=x.error)==null?void 0:ee.message)??null,Te=E?U(E.totalBytes??E.sizeBytes):"-",we=U(E==null?void 0:E.memoryRssBytes),Ee=u.useMemo(()=>{const d=S.map(f=>f.date),h=s("dashboard.charts.barRequests"),_=s("dashboard.charts.lineInput"),P=s("dashboard.charts.lineOutput"),b=s("dashboard.charts.lineCacheRead"),se=s("dashboard.charts.lineCacheCreation");return{tooltip:{trigger:"axis"},legend:{data:[h,_,P,b,se]},grid:{left:56,right:28,top:56,bottom:54},xAxis:{type:"category",data:d},yAxis:{type:"value"},series:[{name:h,type:"bar",data:S.map(f=>f.requestCount),itemStyle:{color:T.requests,borderRadius:[6,6,0,0]}},{name:_,type:"line",smooth:!0,data:S.map(f=>f.inputTokens),itemStyle:{color:T.input},lineStyle:{width:2}},{name:P,type:"line",smooth:!0,data:S.map(f=>f.outputTokens),itemStyle:{color:T.output},lineStyle:{width:2}},{name:b,type:"line",smooth:!0,data:S.map(f=>f.cacheReadTokens),itemStyle:{color:T.cacheRead},lineStyle:{width:2}},{name:se,type:"line",smooth:!0,data:S.map(f=>f.cacheCreationTokens),itemStyle:{color:T.cacheCreation},lineStyle:{width:2}}]}},[S,s]),Ie=u.useMemo(()=>{const d=p.map(b=>`${b.provider}/${b.model}`),h=s("dashboard.charts.barRequests"),_=s("dashboard.charts.lineInput"),P=s("dashboard.charts.lineOutput");return{tooltip:{trigger:"axis"},legend:{data:[h,_,P]},grid:{left:72,right:52,top:56,bottom:96},xAxis:{type:"category",data:d,axisLabel:{rotate:28}},yAxis:[{type:"value",name:h},{type:"value",name:s("dashboard.charts.axisTokens"),position:"right"}],series:[{name:h,type:"bar",data:p.map(b=>b.requests),itemStyle:{color:T.requests,borderRadius:[6,6,0,0]}},{name:_,type:"line",yAxisIndex:1,smooth:!0,data:p.map(b=>b.inputTokens??0),itemStyle:{color:T.input}},{name:P,type:"line",yAxisIndex:1,smooth:!0,data:p.map(b=>b.outputTokens??0),itemStyle:{color:T.output}}]}},[p,s]),Le=u.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:p.map(d=>`${d.provider}/${d.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:s("dashboard.charts.ttftAxis")},series:[{name:s("dashboard.charts.ttftLabel"),type:"bar",data:p.map(d=>d.avgTtftMs??0),itemStyle:{color:T.latency,borderRadius:[6,6,0,0]}}]}),[p,s]),ke=u.useMemo(()=>({tooltip:{trigger:"axis"},grid:{left:72,right:40,top:56,bottom:96},xAxis:{type:"category",data:p.map(d=>`${d.provider}/${d.model}`),axisLabel:{rotate:28}},yAxis:{type:"value",name:s("dashboard.charts.tpotAxis")},series:[{name:s("dashboard.charts.tpotLabel"),type:"bar",data:p.map(d=>d.avgTpotMs??0),itemStyle:{color:T.output,borderRadius:[6,6,0,0]}}]}),[p,s]);return{compacting:o,customEndpoints:((te=n.data)==null?void 0:te.endpoints)??[],daily:S,dailyOption:Ee,dailyPending:m.isPending,dbInfo:E,dbSizeDisplay:Te,endpointFilter:a,fastestTtftModel:ye,handleCompact:he,handleRefresh:me,bootstrapError:Se,isBootstrapping:Ne,isRefreshing:ve,latestLogsPending:N.isPending,memoryDisplay:we,modelRequestsOption:Ie,modelUsagePending:v.isPending,models:p,overview:pe,recentLogs:ue,selectedEndpointLabel:ge,setEndpointFilter:r,status:xe,topModel:je,totalRequestsInRange:be,busiestDay:fe,ttftOption:Le,tpotOption:ke}}function Pt(){var r,o;const{t:s}=w(),t=ht(),a=t.recentLogs.length===0||t.models.length===0;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx($e,{info:e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s("dashboard.filters.endpoint")," · ",t.selectedEndpointLabel]}),actions:e.jsxs(e.Fragment,{children:[e.jsxs(Ve,{value:t.endpointFilter,onValueChange:t.setEndpointFilter,children:[e.jsx(Ke,{className:"h-8 w-[168px]",children:e.jsx(We,{})}),e.jsxs(Ye,{children:[e.jsx(q,{value:"all",children:s("dashboard.filters.endpointAll")}),e.jsx(q,{value:"anthropic",children:s("dashboard.filters.endpointAnthropic")}),e.jsx(q,{value:"openai",children:s("dashboard.filters.endpointOpenAI")}),t.customEndpoints.map(c=>e.jsx(q,{value:c.id,children:c.label||c.id},c.id))]})]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>void t.handleRefresh(),disabled:t.isRefreshing,children:[e.jsx(Fe,{className:C("mr-2 h-4 w-4",t.isRefreshing&&"animate-spin"),"aria-hidden":"true"}),t.isRefreshing?s("common.actions.refreshing"):s("common.actions.refresh")]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>void t.handleCompact(),disabled:t.compacting,children:[e.jsx(ne,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),t.compacting?s("dashboard.actions.compacting"):s("dashboard.actions.compact")]})]})}),t.isBootstrapping?e.jsx(rt,{}):t.bootstrapError?e.jsx(G,{icon:e.jsx(Oe,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:t.bootstrapError,action:e.jsx(D,{variant:"outline",onClick:()=>void t.handleRefresh(),children:s("common.actions.refresh")})}):e.jsxs(e.Fragment,{children:[e.jsx(ot,{selectedEndpointLabel:t.selectedEndpointLabel,status:t.status,todayRequests:((r=t.overview)==null?void 0:r.today.requests)??0}),a?e.jsx(dt,{endpointCount:t.customEndpoints.length,providerCount:((o=t.status)==null?void 0:o.providers)??0,selectedEndpointLabel:t.selectedEndpointLabel}):null,e.jsx(nt,{dbSizeDisplay:t.dbSizeDisplay,memoryDisplay:t.memoryDisplay,overview:t.overview,status:t.status}),e.jsx(it,{busiestDay:t.busiestDay,fastestTtftModel:t.fastestTtftModel,topModel:t.topModel,totalRequestsInRange:t.totalRequestsInRange}),e.jsx(lt,{dailyEmpty:!t.daily.length,dailyOption:t.dailyOption,dailyPending:t.dailyPending,models:t.models,modelRequestsOption:t.modelRequestsOption,modelUsagePending:t.modelUsagePending,ttftOption:t.ttftOption,tpotOption:t.tpotOption}),e.jsx(ct,{models:t.models,loading:t.modelUsagePending}),e.jsx(mt,{records:t.recentLogs,loading:t.latestLogsPending})]})]})}export{Pt as default};
@@ -1 +1 @@
1
- import{r,j as s,a7 as g}from"./vendor-z22RpOY0.js";import{F as u,G as d,H as n,J as y,K as l,M as b,O as i}from"./radix-mHySgtou.js";import{c as o}from"./global-B-NXh5qD.js";const k=u,N=y,c=r.forwardRef(({className:a,...e},t)=>s.jsx(i,{ref:t,className:o("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...e}));c.displayName=i.displayName;const p=r.forwardRef(({className:a,children:e,...t},x)=>s.jsxs(N,{children:[s.jsx(c,{}),s.jsxs(l,{ref:x,className:o("fixed left-[50%] top-[50%] z-50 flex max-h-[85vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-xl border border-border bg-background p-6 shadow-[var(--surface-shadow-lg)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",a),...t,children:[e,s.jsxs(b,{className:"absolute right-4 top-4 rounded-md p-1.5 text-muted-foreground opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(g,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));p.displayName=l.displayName;const m=({className:a,...e})=>s.jsx("div",{className:o("flex shrink-0 flex-col space-y-1.5 text-center sm:text-left",a),...e});m.displayName="DialogHeader";const f=({className:a,...e})=>s.jsx("div",{className:o("flex shrink-0 flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...e});f.displayName="DialogFooter";const j=r.forwardRef(({className:a,...e},t)=>s.jsx(d,{ref:t,className:o("text-lg font-semibold leading-none tracking-[-0.02em]",a),...e}));j.displayName=d.displayName;const D=r.forwardRef(({className:a,...e},t)=>s.jsx(n,{ref:t,className:o("text-sm leading-6 text-muted-foreground",a),...e}));D.displayName=n.displayName;function R({children:a,className:e}){return s.jsx(p,{className:o("gap-0 overflow-hidden p-0",e),children:a})}function A({children:a,className:e}){return s.jsx("div",{className:o("border-b border-border bg-secondary/40 px-6 py-5",e),children:s.jsx(m,{children:a})})}function C({children:a,className:e}){return s.jsx("div",{className:o("min-h-0 overflow-y-auto px-6 py-5",e),children:a})}function z({children:a,className:e}){return s.jsx(f,{className:o("border-t border-border bg-secondary/40 px-6 py-4",e),children:a})}export{R as A,k as D,A as a,j as b,D as c,C as d,z as e};
1
+ import{r,j as s,a7 as g}from"./vendor-DdPBfMMb.js";import{F as u,G as d,H as n,J as y,K as l,M as b,O as i}from"./radix-CtQBp6Ie.js";import{c as o}from"./global-D8DuA4wF.js";const k=u,N=y,c=r.forwardRef(({className:a,...e},t)=>s.jsx(i,{ref:t,className:o("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...e}));c.displayName=i.displayName;const p=r.forwardRef(({className:a,children:e,...t},x)=>s.jsxs(N,{children:[s.jsx(c,{}),s.jsxs(l,{ref:x,className:o("fixed left-[50%] top-[50%] z-50 flex max-h-[85vh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-xl border border-border bg-background p-6 shadow-[var(--surface-shadow-lg)] duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",a),...t,children:[e,s.jsxs(b,{className:"absolute right-4 top-4 rounded-md p-1.5 text-muted-foreground opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(g,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));p.displayName=l.displayName;const m=({className:a,...e})=>s.jsx("div",{className:o("flex shrink-0 flex-col space-y-1.5 text-center sm:text-left",a),...e});m.displayName="DialogHeader";const f=({className:a,...e})=>s.jsx("div",{className:o("flex shrink-0 flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...e});f.displayName="DialogFooter";const j=r.forwardRef(({className:a,...e},t)=>s.jsx(d,{ref:t,className:o("text-lg font-semibold leading-none tracking-[-0.02em]",a),...e}));j.displayName=d.displayName;const D=r.forwardRef(({className:a,...e},t)=>s.jsx(n,{ref:t,className:o("text-sm leading-6 text-muted-foreground",a),...e}));D.displayName=n.displayName;function R({children:a,className:e}){return s.jsx(p,{className:o("gap-0 overflow-hidden p-0",e),children:a})}function A({children:a,className:e}){return s.jsx("div",{className:o("border-b border-border bg-secondary/40 px-6 py-5",e),children:s.jsx(m,{children:a})})}function C({children:a,className:e}){return s.jsx("div",{className:o("min-h-0 overflow-y-auto px-6 py-5",e),children:a})}function z({children:a,className:e}){return s.jsx(f,{className:o("border-t border-border bg-secondary/40 px-6 py-4",e),children:a})}export{R as A,k as D,A as a,j as b,D as c,C as d,z as e};
@@ -0,0 +1 @@
1
+ import{r as p,j as e,ax as z,aA as F,U as k,aB as R,aC as I,aD as B,a0 as D,aE as V}from"./vendor-DdPBfMMb.js";import{L as q}from"./router-D2Fb4U0L.js";import{P as K}from"./PageToolbar-BxRZF-QJ.js";import{P as Q}from"./PageSection-DVs3faWw.js";import{P as U,a as E}from"./PageState-Dvjip2P-.js";import{u as G}from"./useApiQuery-4gJC8RZB.js";import{c as T}from"./global-D8DuA4wF.js";import{u as J,B as c}from"./app-DkubSF6m.js";import{B as u,q as O}from"./queryKeys-BpeJfcg0.js";import{C as N,a as y}from"./card-Bx5Pg_wP.js";import{I as H}from"./input-b5NRkUKN.js";import{S as W,a as X,b as Y,c as Z,d as g}from"./select-B5oPLG9G.js";import{u as _}from"./i18n-C8tBby0x.js";import"./query-QCek5MsK.js";import"./radix-CtQBp6Ie.js";function ee(s){const i=Date.now()-s,n=Math.abs(i),l=60*1e3,m=60*l,h=24*m;if(n<l){const o=Math.max(Math.round(n/1e3),1);return i>=0?`${o}s ago`:`in ${o}s`}if(n<m){const o=Math.round(n/l);return i>=0?`${o}m ago`:`in ${o}m`}if(n<h){const o=Math.round(n/m);return i>=0?`${o}h ago`:`in ${o}h`}const r=Math.round(n/h);return i>=0?`${r}d ago`:`in ${r}d`}function se(s){return new Date(s).toLocaleString()}const te={info:"secondary",warn:"outline",error:"destructive"};function je(){var C,S,L;const{t:s}=_(),{pushToast:a}=J(),[i,n]=p.useState(null),[l,m]=p.useState({level:"",type:""}),h=p.useMemo(()=>({limit:50,cursor:i??void 0,level:l.level||void 0,type:l.type.trim()||void 0}),[i,l.level,l.type]),r=G(O.events.list(h),{url:"/api/events",method:"GET",params:h});p.useEffect(()=>{r.isError&&r.error&&a({title:s("events.toast.loadFailure",{message:r.error.message}),variant:"error"})},[r.error,r.isError,a,s]);const o=()=>{n(null),m({level:"",type:""})},d=((C=r.data)==null?void 0:C.events)??[],b=((S=r.data)==null?void 0:S.nextCursor)??null,A=r.isLoading,v=r.isFetching&&!r.isLoading,x=p.useMemo(()=>{const t=[];return l.level&&t.push(s(`events.levels.${l.level}`)),l.type.trim()&&t.push(l.type.trim()),t},[l.level,l.type,s]),P=d.filter(t=>t.level==="info").length,M=d.filter(t=>t.level==="warn").length,$=d.filter(t=>t.level==="error").length;return e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(K,{info:d.length>0?e.jsxs("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:[d.length," events"]}):null,status:e.jsx("span",{className:"text-xs text-muted-foreground",children:s(i?"events.actions.older":"events.actions.newest")}),actions:e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>void r.refetch(),disabled:v,children:[e.jsx(z,{className:T("mr-2 h-4 w-4",v&&"animate-spin"),"aria-hidden":"true"}),s(v?"common.actions.refreshing":"common.actions.refresh")]})}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsx(w,{icon:e.jsx(F,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.info"),value:P.toLocaleString(),tone:"emerald"}),e.jsx(w,{icon:e.jsx(k,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.warn"),value:M.toLocaleString(),tone:"amber"}),e.jsx(w,{icon:e.jsx(R,{className:"h-4 w-4","aria-hidden":"true"}),title:s("events.levels.error"),value:$.toLocaleString(),tone:"rose"})]}),e.jsx(N,{"data-testid":"events-filters-card",className:"overflow-hidden rounded-[1.25rem] border border-white/70 bg-card/95 shadow-[0_20px_50px_-42px_rgba(15,23,42,0.24)]",children:e.jsx(y,{className:"space-y-3 p-4",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[e.jsx(I,{className:"h-4 w-4 text-primary","aria-hidden":"true"}),s("events.filters.title"),e.jsx(u,{variant:"outline",children:d.length})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("events.description")})]}),e.jsxs("div",{className:"grid gap-2 sm:flex sm:flex-wrap sm:items-center",children:[x.length>0?e.jsx(c,{variant:"ghost",size:"sm",onClick:o,className:"h-8 rounded-full px-3 text-xs sm:w-auto",children:s("common.actions.reset")}):null,e.jsxs(c,{variant:"outline",size:"sm",disabled:!i,onClick:()=>n(null),className:"h-8 rounded-full px-3 text-xs sm:w-auto",children:[e.jsx(B,{className:"mr-1 h-4 w-4","aria-hidden":"true"}),s("events.actions.newest")]}),e.jsxs(c,{variant:"outline",size:"sm",disabled:!b,onClick:()=>n(b),className:"h-8 rounded-full px-3 text-xs sm:w-auto",children:[s("events.actions.older"),e.jsx(D,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:flex-wrap md:items-center",children:[e.jsxs(W,{value:l.level,onValueChange:t=>{n(null),m(j=>({...j,level:t==="all"?"":t}))},children:[e.jsx(X,{className:"w-full md:w-[160px]",children:e.jsx(Y,{placeholder:s("events.filters.allLevels")})}),e.jsxs(Z,{children:[e.jsx(g,{value:"all",children:s("events.filters.allLevels")}),e.jsx(g,{value:"info",children:s("events.levels.info")}),e.jsx(g,{value:"warn",children:s("events.levels.warn")}),e.jsx(g,{value:"error",children:s("events.levels.error")})]})]}),e.jsx(H,{className:"w-full md:w-[220px]",placeholder:s("events.filters.typePlaceholder"),value:l.type,onChange:t=>{n(null),m(j=>({...j,type:t.target.value}))}}),e.jsx(c,{variant:"ghost",size:"sm",onClick:o,disabled:x.length===0,className:"h-8 rounded-full px-3 text-xs md:w-auto",children:s("common.actions.reset")})]}),x.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(t=>e.jsx(u,{variant:"secondary",children:t},t))}):null]})})}),e.jsx(Q,{title:s("events.title"),description:s(i?"events.actions.older":"events.actions.newest"),children:A?e.jsx(U,{label:s("common.loading")}):r.isError?e.jsx(E,{icon:e.jsx(k,{className:"h-5 w-5","aria-hidden":"true"}),tone:"danger",title:s("common.status.error"),description:s("events.toast.loadFailure",{message:((L=r.error)==null?void 0:L.message)??s("common.unknownError")}),action:e.jsx(c,{variant:"outline",size:"sm",onClick:()=>void r.refetch(),children:s("common.actions.refresh")})}):d.length===0?e.jsx(E,{icon:e.jsx(V,{className:"h-5 w-5","aria-hidden":"true"}),tone:"primary",title:x.length>0?s("events.empty.filteredTitle"):s("events.empty.title"),description:x.length>0?s("events.empty.filteredSubtitle"):s("events.empty.subtitle"),action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[x.length>0?e.jsx(c,{variant:"outline",size:"sm",onClick:o,children:s("common.actions.reset")}):null,e.jsx(c,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(q,{to:"/logs",children:s("events.empty.actions.logs")})})]})}):e.jsx("div",{className:"grid gap-3",children:d.map(t=>e.jsx(re,{event:t},t.id))})})]})}function w({icon:s,title:a,tone:i,value:n}){return e.jsx(N,{className:"rounded-[1.15rem] border border-white/70 bg-card/95 shadow-[0_18px_42px_-38px_rgba(15,23,42,0.22)]",children:e.jsxs(y,{className:"flex items-center justify-between gap-3 p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:a}),e.jsx("p",{className:"metric-number mt-1 text-[1.85rem] font-bold tracking-tight text-foreground",children:n})]}),e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-secondary text-muted-foreground",children:s})]})})}function re({event:s}){const{t:a}=_(),i=s.level==="error"?"border-l-destructive":s.level==="warn"?"border-l-amber-500":"border-l-emerald-500";return e.jsx(N,{className:T("overflow-hidden rounded-[1.05rem] border border-white/70 border-l-2 bg-card/96 shadow-[0_18px_38px_-34px_rgba(15,23,42,0.2)]",i),children:e.jsxs(y,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(u,{variant:te[s.level]||"secondary",className:"rounded-full text-[10px]",children:a(`events.levels.${s.level}`)}),e.jsxs(u,{variant:"outline",className:"rounded-full text-[10px]",children:["#",s.id]}),s.mode?e.jsx(u,{variant:"secondary",className:"rounded-full text-[10px]",children:s.mode}):null,s.endpoint?e.jsx(u,{variant:"outline",className:"rounded-full text-[10px]",children:s.endpoint}):null]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-[15px] font-semibold tracking-[-0.01em]",children:s.title||a("events.defaultTitle")}),e.jsx("p",{className:"mt-1 line-clamp-2 text-sm leading-5 text-muted-foreground",children:s.message||a("events.defaultMessage")})]})]}),e.jsxs("div",{className:"shrink-0 space-y-0.5 text-xs text-muted-foreground lg:text-right",children:[e.jsx("p",{children:se(s.createdAt)}),e.jsx("p",{children:ee(s.createdAt)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm",children:[e.jsx(f,{label:"Type",value:s.type}),e.jsx(f,{label:"Source",value:s.source}),e.jsx(f,{label:"IP",value:s.ipAddress}),e.jsx(f,{label:"API Key",value:s.apiKeyName}),e.jsx(f,{label:"User Agent",value:s.userAgent})]}),s.details?e.jsxs("details",{className:"rounded-[0.9rem] bg-secondary/50 px-3 py-2 text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-medium text-primary",children:a("events.details")}),e.jsx("pre",{className:"mt-2.5 overflow-x-auto rounded-lg bg-secondary p-3 text-xs leading-6",children:JSON.stringify(s.details,null,2)})]}):null]})})}function f({label:s,value:a}){return a?e.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border/60 bg-secondary/55 px-2.5 py-1 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"font-medium",children:[s,":"]}),e.jsx("span",{className:"truncate text-foreground",title:a,children:a})]}):null}export{je as default};
@@ -0,0 +1,4 @@
1
+ import{r as u,j as e}from"./vendor-DdPBfMMb.js";import{P as f}from"./PageToolbar-BxRZF-QJ.js";import{P as o}from"./PageSection-DVs3faWw.js";import{c as j}from"./clipboard-CALi6bTW.js";import{c as x}from"./global-D8DuA4wF.js";import{B as b}from"./app-DkubSF6m.js";import{u as h}from"./i18n-C8tBby0x.js";import"./query-QCek5MsK.js";import"./router-D2Fb4U0L.js";import"./radix-CtQBp6Ie.js";function P(){const{t}=h(),s=u.useMemo(()=>[{id:"tour",title:t("help.sections.consoleTour.title"),items:t("help.sections.consoleTour.items",{returnObjects:!0})},{id:"configuration",title:t("help.sections.configuration.title"),items:t("help.sections.configuration.items",{returnObjects:!0})},{id:"claude",title:t("help.sections.claudeCodeConfig.title"),items:t("help.sections.claudeCodeConfig.items",{returnObjects:!0})},{id:"codex",title:t("help.sections.codexConfig.title"),items:t("help.sections.codexConfig.items",{returnObjects:!0})},{id:"usage",title:t("help.sections.usage.title"),items:t("help.sections.usage.items",{returnObjects:!0})},{id:"tips",title:t("help.sections.tips.title"),items:t("help.sections.tips.items",{returnObjects:!0})}],[t]),i=t("help.faq.items",{returnObjects:!0}),l=u.useMemo(()=>[...s.map(n=>({id:n.id,title:n.title})),{id:"faq",title:t("help.faq.title")}],[s,t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(f,{info:e.jsx("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:t("help.meta.guides",{count:s.length})})}),e.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/80 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:t("help.note")}),e.jsx("p",{className:"mt-1 text-xs leading-5",children:t("help.helper")})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[208px_minmax(0,1fr)] xl:items-start",children:[e.jsx("aside",{className:"hidden xl:sticky xl:top-4 xl:block",children:e.jsxs("nav",{"aria-label":t("help.meta.tocTitle"),className:"rounded-lg border border-border/60 bg-card/70 p-3",children:[e.jsx("p",{className:"mb-2 px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:t("help.meta.tocTitle")}),e.jsx("ol",{className:"space-y-0.5 text-sm",children:l.map(n=>e.jsx("li",{children:e.jsx("a",{href:`#help-${n.id}`,className:"block truncate rounded-md px-2 py-1.5 text-muted-foreground transition hover:bg-accent hover:text-foreground",children:n.title})},n.id))})]})}),e.jsxs("div",{className:"min-w-0 space-y-5",children:[e.jsx("div",{id:"help-tour",children:e.jsx(o,{title:s[0].title,children:e.jsx(c,{items:s[0].items,compact:!0})})}),e.jsx("div",{id:"help-configuration",children:e.jsx(o,{title:s[1].title,children:e.jsx(c,{items:s[1].items})})}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsx(o,{title:s[2].title,description:t("help.meta.claudeWorkflow"),children:e.jsx(c,{items:s[2].items})})}),e.jsx("div",{id:"help-codex",children:e.jsx(o,{title:s[3].title,description:t("help.meta.codexWorkflow"),children:e.jsx(c,{items:s[3].items})})})]}),e.jsx("div",{id:"help-usage",children:e.jsx(o,{title:s[4].title,children:e.jsx(c,{items:s[4].items})})}),e.jsx("div",{id:"help-tips",children:e.jsx(o,{title:s[5].title,children:e.jsx(c,{items:s[5].items})})}),e.jsx("div",{id:"help-faq",children:e.jsx(o,{title:t("help.faq.title"),children:e.jsx(y,{items:i})})})]})]})]})}function c({items:t,compact:s=!1}){return e.jsx("ol",{className:x("flex flex-col",s?"gap-2":"gap-2.5"),children:t.map((i,l)=>e.jsxs("li",{className:x("flex gap-3 rounded-lg border border-border/50 bg-card/80",s?"p-3":"p-3.5"),children:[e.jsx("span",{className:x("flex shrink-0 items-center justify-center rounded-md bg-primary text-xs font-semibold text-primary-foreground",s?"h-6 w-6 text-[11px]":"h-7 w-7"),children:l+1}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-muted-foreground",children:e.jsx(g,{content:i})})]},`${l}-${i}`))})}function g({content:t}){const{t:s}=h(),i=t.split("```");return e.jsx("div",{className:"space-y-3",children:i.map((l,n)=>{if(!l.trim())return null;if(n%2===1){const[a,...m]=l.split(`
2
+ `),r=m.join(`
3
+ `).trim();return e.jsxs("div",{className:"overflow-hidden rounded-md border border-border/55 bg-secondary/60 dark:border-white/10 dark:bg-slate-900/[0.52]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/55 px-3 py-1.5 dark:border-white/10",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:a||"bash"}),e.jsx(b,{variant:"ghost",size:"sm",className:"h-6 rounded px-2 text-[11px] text-muted-foreground hover:text-foreground",onClick:()=>j(r),children:s("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto px-3 py-2.5 font-mono text-[12px] leading-6 text-foreground",children:e.jsx("code",{className:"block min-w-full whitespace-pre",children:r})})]},n)}return e.jsx(N,{content:l},n)})})}function N({content:t}){const s=t.split(`
4
+ `).map(r=>r.trimEnd()).filter(r=>r.trim().length>0);if(s.length===0)return null;const i=s.filter(r=>/^[-•*]\s+/.test(r.trim())),l=s.filter(r=>/^\d+[).]\s+/.test(r.trim())),n=s.filter(r=>!/^([-•*]|\d+[).])\s+/.test(r.trim())),a=i.map(r=>r.replace(/^[-•*]\s+/,"")),m=l.map(r=>{const d=r.trim().match(/^(\d+)[).]\s+(.*)$/);return{index:(d==null?void 0:d[1])??"",text:(d==null?void 0:d[2])??r.trim()}});return e.jsxs("div",{className:"space-y-2",children:[n.length>0?e.jsx("div",{className:"space-y-1.5",children:n.map((r,d)=>e.jsx("p",{className:"leading-6",children:p(r)},`${r}-${d}`))}):null,a.length>0?e.jsx("ul",{className:"space-y-1.5 rounded-md bg-secondary/40 px-3 py-2 dark:bg-slate-900/[0.34]",children:a.map((r,d)=>e.jsxs("li",{className:"flex gap-2 text-sm leading-6",children:[e.jsx("span",{className:"mt-2 h-1.5 w-1.5 shrink-0 rounded-full bg-primary"}),e.jsx("span",{children:p(r)})]},`${r}-${d}`))}):null,m.length>0?e.jsx("ol",{className:"space-y-1.5 rounded-md bg-secondary/40 px-3 py-2 dark:bg-slate-900/[0.34]",children:m.map(r=>e.jsxs("li",{className:"flex gap-2.5 text-sm leading-6",children:[e.jsx("span",{className:"mt-0.5 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary/15 px-1.5 text-[11px] font-semibold text-primary",children:r.index}),e.jsx("span",{children:p(r.text)})]},`${r.index}-${r.text}`))}):null]})}function p(t){return t.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).map((i,l)=>i.startsWith("`")&&i.endsWith("`")?e.jsx("code",{className:"rounded bg-secondary/72 px-1.5 py-0.5 text-[0.95em] text-foreground dark:bg-slate-900/[0.58]",children:i.slice(1,-1)},l):i.startsWith("**")&&i.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:i.slice(2,-2)},l):e.jsx("span",{children:i},l))}function y({items:t}){return t.length===0?null:e.jsx("dl",{className:"space-y-2",children:t.map((s,i)=>e.jsxs("details",{className:"group overflow-hidden rounded-lg border border-border/50 bg-card/80",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-2.5 text-sm font-medium text-foreground",children:[e.jsx("span",{children:s.q}),e.jsx("span",{className:"rounded-full bg-secondary px-2 py-0.5 text-[11px] text-muted-foreground transition group-open:bg-primary/10 group-open:text-primary",children:i+1})]}),e.jsx("div",{className:"border-t border-border/50 px-4 py-3",children:e.jsx("dd",{className:"text-sm text-muted-foreground",children:e.jsx(g,{content:s.a})})})]},s.q))})}export{P as default};
@@ -1 +1 @@
1
- import{r as n,j as e,aB as S,aV as E}from"./vendor-z22RpOY0.js";import{h as k,L as F,B as L}from"./app-COiQeF3y.js";import{C as j,a as N,b as B,c as P,d as T,e as A}from"./card-ChFVaqLf.js";import{I as b}from"./input-DW7jGTgj.js";import{L as y}from"./label-Ci1io7XA.js";import{u as D}from"./i18n-Bl2BcCDG.js";import{c as G,u as I}from"./router-CL3rf_uf.js";import"./global-B-NXh5qD.js";import"./query-BbGWgOFk.js";import"./radix-mHySgtou.js";function O(){const{t:s}=D(),a=G(),l=I(),{authEnabled:o,isAuthenticated:u,loading:c,login:v,error:x}=k(),[i,p]=n.useState({username:"",password:""}),[h,m]=n.useState(null),[f,g]=n.useState(!1),d=n.useMemo(()=>{var r;const t=l.state;return((r=t==null?void 0:t.from)==null?void 0:r.pathname)??"/"},[l.state]);n.useEffect(()=>{if(!o&&!c){a(d,{replace:!0});return}o&&u&&!c&&a(d,{replace:!0})},[o,d,u,c,a]);const C=async t=>{if(t.preventDefault(),m(null),!i.username.trim()||!i.password){m(s("login.validation.required"));return}g(!0);try{await v(i.username.trim(),i.password),a(d,{replace:!0})}catch(r){m(r instanceof Error?r.message:s("login.validation.failed"))}finally{g(!1)}};return c?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsx(j,{className:"w-full max-w-md",children:e.jsx(N,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(F,{})})})}):o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4 py-10",children:e.jsxs("div",{className:"mx-auto grid w-full max-w-5xl items-center gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(400px,0.8fr)]",children:[e.jsx("div",{className:"hidden lg:block",children:e.jsxs("div",{className:"max-w-lg space-y-6",children:[e.jsx("div",{className:"inline-flex items-center gap-1.5 rounded-full bg-primary/10 px-3 py-1 text-xs font-semibold text-primary",children:"Secure Gateway Control"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-foreground",children:s("login.title")}),e.jsx("p",{className:"max-w-md text-base leading-7 text-muted-foreground",children:s("login.description")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(w,{icon:e.jsx(S,{className:"h-5 w-5","aria-hidden":"true"}),title:s("login.hint"),description:s("about.support.tip")}),e.jsx(w,{icon:e.jsx(E,{className:"h-5 w-5","aria-hidden":"true"}),title:"Session protected",description:s("help.note")})]})]})}),e.jsxs(j,{className:"w-full",children:[e.jsxs(B,{className:"pb-4 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground",children:"GW"}),e.jsx(P,{className:"text-xl",children:s("login.title")}),e.jsx(T,{children:s("login.description")})]}),e.jsx(N,{children:e.jsxs("form",{className:"space-y-4",onSubmit:C,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(b,{id:"username",value:i.username,autoComplete:"username",autoFocus:!0,onChange:t=>p(r=>({...r,username:t.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(b,{id:"password",type:"password",value:i.password,autoComplete:"current-password",onChange:t=>p(r=>({...r,password:t.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),h||x?e.jsx("div",{className:"rounded-lg bg-destructive/10 px-4 py-3 text-sm text-destructive",children:h||x}):null,e.jsx(L,{type:"submit",className:"w-full",disabled:f,children:s(f?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(A,{className:"justify-center pt-2",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})]})}):null}function w({description:s,icon:a,title:l}){return e.jsxs("div",{className:"rounded-lg bg-card px-4 py-4 shadow-[var(--surface-shadow)]",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:a}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-foreground",children:l}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s})]})}export{O as default};
1
+ import{r as n,j as e,aA as S,aS as E}from"./vendor-DdPBfMMb.js";import{h as k,L as F,B as L}from"./app-DkubSF6m.js";import{C as j,a as N,b as A,c as P,d as T,e as B}from"./card-Bx5Pg_wP.js";import{I as b}from"./input-b5NRkUKN.js";import{L as y}from"./label-DUoPO5Jo.js";import{u as D}from"./i18n-C8tBby0x.js";import{c as G,u as I}from"./router-D2Fb4U0L.js";import"./global-D8DuA4wF.js";import"./query-QCek5MsK.js";import"./radix-CtQBp6Ie.js";function Q(){const{t:s}=D(),a=G(),l=I(),{authEnabled:o,isAuthenticated:u,loading:c,login:v,error:x}=k(),[i,p]=n.useState({username:"",password:""}),[h,m]=n.useState(null),[f,g]=n.useState(!1),d=n.useMemo(()=>{var r;const t=l.state;return((r=t==null?void 0:t.from)==null?void 0:r.pathname)??"/"},[l.state]);n.useEffect(()=>{if(!o&&!c){a(d,{replace:!0});return}o&&u&&!c&&a(d,{replace:!0})},[o,d,u,c,a]);const C=async t=>{if(t.preventDefault(),m(null),!i.username.trim()||!i.password){m(s("login.validation.required"));return}g(!0);try{await v(i.username.trim(),i.password),a(d,{replace:!0})}catch(r){m(r instanceof Error?r.message:s("login.validation.failed"))}finally{g(!1)}};return c?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4",children:e.jsx(j,{className:"w-full max-w-md",children:e.jsx(N,{className:"flex min-h-[320px] items-center justify-center",children:e.jsx(F,{})})})}):o?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-4 py-10",children:e.jsxs("div",{className:"mx-auto grid w-full max-w-5xl items-center gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(400px,0.8fr)]",children:[e.jsx("div",{className:"hidden lg:block",children:e.jsxs("div",{className:"max-w-lg space-y-6",children:[e.jsx("div",{className:"inline-flex items-center gap-1.5 rounded-full bg-primary/10 px-3 py-1 text-xs font-semibold text-primary",children:"Secure Gateway Control"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-foreground",children:s("login.title")}),e.jsx("p",{className:"max-w-md text-base leading-7 text-muted-foreground",children:s("login.description")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(w,{icon:e.jsx(S,{className:"h-5 w-5","aria-hidden":"true"}),title:s("login.hint"),description:s("about.support.tip")}),e.jsx(w,{icon:e.jsx(E,{className:"h-5 w-5","aria-hidden":"true"}),title:"Session protected",description:s("help.note")})]})]})}),e.jsxs(j,{className:"w-full",children:[e.jsxs(A,{className:"pb-4 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground",children:"GW"}),e.jsx(P,{className:"text-xl",children:s("login.title")}),e.jsx(T,{children:s("login.description")})]}),e.jsx(N,{children:e.jsxs("form",{className:"space-y-4",onSubmit:C,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"username",children:s("login.fields.username")}),e.jsx(b,{id:"username",value:i.username,autoComplete:"username",autoFocus:!0,onChange:t=>p(r=>({...r,username:t.target.value})),placeholder:s("login.fields.usernamePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"password",children:s("login.fields.password")}),e.jsx(b,{id:"password",type:"password",value:i.password,autoComplete:"current-password",onChange:t=>p(r=>({...r,password:t.target.value})),placeholder:s("login.fields.passwordPlaceholder")})]}),h||x?e.jsx("div",{className:"rounded-lg bg-destructive/10 px-4 py-3 text-sm text-destructive",children:h||x}):null,e.jsx(L,{type:"submit",className:"w-full",disabled:f,children:s(f?"common.actions.loading":"login.actions.submit")})]})}),e.jsx(B,{className:"justify-center pt-2",children:e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:s("login.hint")})})]})]})}):null}function w({description:s,icon:a,title:l}){return e.jsxs("div",{className:"rounded-lg bg-card px-4 py-4 shadow-[var(--surface-shadow)]",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:a}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-foreground",children:l}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s})]})}export{Q as default};
@@ -0,0 +1 @@
1
+ import{r as m,j as e,ay as Xe,al as Ze,a7 as Ye,az as et,ax as tt,U as st,P as lt}from"./vendor-DdPBfMMb.js";import{P as at}from"./PageToolbar-BxRZF-QJ.js";import{c as j}from"./global-D8DuA4wF.js";import{B as _,b as rt,u as fe,s as D,t as ot,a as K}from"./app-DkubSF6m.js";import{B as A,q as V}from"./queryKeys-BpeJfcg0.js";import{C as Ee,a as De}from"./card-Bx5Pg_wP.js";import{I as xe}from"./input-b5NRkUKN.js";import{L as U}from"./label-DUoPO5Jo.js";import{S as te,a as se,b as le,c as ae,d as M}from"./select-B5oPLG9G.js";import{u as P}from"./i18n-C8tBby0x.js";import{D as it,A as nt,a as dt,b as ct,c as pt,d as ut}from"./DialogShell-BWia_d99.js";import{P as mt,a as re}from"./PageState-Dvjip2P-.js";import{c as xt}from"./clipboard-CALi6bTW.js";import{u as B}from"./useApiQuery-4gJC8RZB.js";import{g as Fe,f as gt,a as q,b as Te,c as ft,d as Q,e as ht}from"./utils-DSaa7c6v.js";import{P as yt,a as bt,b as jt}from"./popover-BAGiqp11.js";import{L as vt}from"./router-D2Fb4U0L.js";import{T as wt}from"./Skeleton-DHQ8ApGX.js";import{u as Nt}from"./query-QCek5MsK.js";import{g as Ce}from"./gateway-DOu5TM82.js";import"./radix-CtQBp6Ie.js";function kt({apiKeys:l,selected:t,onChange:d,disabled:r,className:c}){const{t:s}=P(),[o,h]=m.useState(!1),x=m.useRef(null);m.useEffect(()=>{if(!o)return;const n=a=>{var i;(i=x.current)!=null&&i.contains(a.target)||h(!1)};return window.addEventListener("mousedown",n),()=>window.removeEventListener("mousedown",n)},[o]);const f=m.useMemo(()=>{if(t.length===0)return[];const n=new Map;for(const a of l)n.set(a.id,a);return t.map(a=>{const i=n.get(a);return i?i.isWildcard?s("apiKeys.wildcard"):i.name:null}).filter(a=>!!a)},[l,t,s]),y=t.length===0?s("logs.filters.apiKeyAll"):s("logs.filters.apiKeySelected",{count:t.length}),g=n=>{t.includes(n)?d(t.filter(a=>a!==n)):d([...t,n])};return e.jsxs("div",{className:j("relative space-y-2",c),ref:x,children:[e.jsx(U,{children:s("logs.filters.apiKey")}),e.jsxs("button",{type:"button",onClick:()=>h(n=>!n),disabled:r||l.length===0,title:s("logs.filters.apiKeyHint"),className:j("flex h-10 w-full items-center justify-between rounded-lg border border-input bg-background px-3 text-sm ring-offset-background transition-all focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t.length>0&&"border-primary",o&&"ring-2 ring-ring ring-offset-2"),children:[e.jsxs("span",{className:"truncate",children:[y,f.length>0&&e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:f.join(", ")})]}),e.jsx("svg",{className:j("h-4 w-4 opacity-50 transition-transform",o&&"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"})})]}),o&&e.jsxs("div",{className:"absolute left-0 top-full z-30 mt-2 w-64 rounded-lg border bg-popover p-2 shadow-[var(--surface-shadow-lg)]",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-secondary px-3 py-2 text-xs",children:[e.jsx("span",{children:y}),e.jsx("button",{type:"button",onClick:()=>d([]),disabled:t.length===0,className:"text-primary hover:underline disabled:opacity-40",children:s("common.actions.reset")})]}),e.jsxs("div",{className:"max-h-56 overflow-y-auto py-2",children:[l.map(n=>{const a=n.isWildcard?s("apiKeys.wildcard"):n.name,i=t.includes(n.id);return e.jsxs("label",{className:j("flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2 text-sm transition hover:bg-primary/5",i&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 rounded border-border",checked:i,onChange:()=>g(n.id)}),e.jsx("span",{className:"truncate",children:a})]},n.id)}),l.length===0&&e.jsx("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:s("logs.filters.apiKeyAll")})]})]})]})}function St(l){const{t}=P(),{total:d,activeFilters:r,filtersExpanded:c,setFiltersExpanded:s,handleResetFilters:o,activeQuickView:h,applyQuickView:x,providerFilter:f,setProviderFilter:y,endpointFilter:g,setEndpointFilter:n,selectedApiKeys:a,setSelectedApiKeys:i,modelFilter:N,setModelFilter:u,statusFilter:E,setStatusFilter:k,fromDate:C,setFromDate:F,toDate:w,setToDate:L,providerOptions:S,apiKeys:G,apiKeysLoading:ie,customEndpoints:J}=l;return e.jsx(Ee,{"data-testid":"logs-filters-card",className:"overflow-hidden rounded-[1.25rem] border border-white/70 bg-card/95 shadow-[0_20px_50px_-42px_rgba(15,23,42,0.24)]",children:e.jsxs(De,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:t("logs.filtersTitle")}),e.jsx(A,{variant:"secondary",className:"rounded-full px-2.5 py-0.5 text-[11px] font-semibold",children:t("logs.summary.total",{value:d.toLocaleString()})}),r.length>0&&e.jsx(A,{variant:"outline",className:"rounded-full border-transparent bg-primary/10 px-2.5 py-0.5 text-[11px] font-semibold text-primary",children:t("common.filters.activeCount",{count:r.length})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("logs.filtersDescription")})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[r.length>0&&e.jsx(_,{variant:"ghost",size:"sm",onClick:o,className:"h-8 rounded-full px-3 text-xs",children:t("common.actions.reset")}),e.jsx(_,{variant:"ghost",size:"sm",onClick:()=>s(b=>!b),className:"h-8 rounded-full px-3 text-xs",children:c?e.jsxs(e.Fragment,{children:[t("common.filters.collapse"),e.jsx(Xe,{className:"ml-1 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:[t("common.filters.expand"),e.jsx(Ze,{className:"ml-1 h-4 w-4"})]})})]})]}),e.jsxs("div",{className:"grid gap-2 lg:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsx("div",{className:"flex min-h-10 items-center rounded-[0.9rem] bg-secondary/70 px-3 py-2",children:r.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.map(b=>e.jsxs(A,{variant:"outline",role:"button",tabIndex:0,className:"flex cursor-pointer items-center gap-1 rounded-full border border-border bg-card/90 px-2.5 py-1 text-[11px] font-semibold text-foreground/90 transition hover:bg-secondary/80",onClick:b.onRemove,onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&(X.preventDefault(),b.onRemove())},children:[b.label,e.jsx(Ye,{className:"h-3 w-3","aria-hidden":"true"})]},b.key))}):e.jsx("span",{className:"text-xs text-muted-foreground",children:t("common.filters.allRequests")})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 lg:justify-end",children:[e.jsx(ge,{label:t("logs.filters.apiKey"),value:a.length.toString()}),e.jsx(ge,{label:t("logs.filters.provider"),value:f==="all"?"0":"1"}),e.jsx(ge,{label:t("logs.filters.endpoint"),value:g==="all"?"0":"1"})]})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 rounded-[0.9rem] bg-secondary/70 px-2 py-1.5",children:["all","errors","today","anthropic","openai"].map(b=>e.jsx(_,{variant:"ghost",size:"sm",className:j("h-7 rounded-full px-3 text-[11px] font-semibold transition-colors",h===b?"bg-card text-foreground shadow-[0_12px_28px_-24px_rgba(15,23,42,0.32)]":"text-muted-foreground"),onClick:()=>x(b),children:t(`logs.quickViews.${b}`)},b))})]}),c&&e.jsxs("div",{className:"mt-3 grid gap-3 rounded-[1rem] bg-secondary/45 p-3 md:grid-cols-2 xl:grid-cols-4 animate-in fade-in slide-in-from-top-2 duration-200",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:t("logs.filters.provider")}),e.jsxs(te,{value:f,onValueChange:y,children:[e.jsx(se,{children:e.jsx(le,{})}),e.jsxs(ae,{children:[e.jsx(M,{value:"all",children:t("logs.filters.providerAll")}),S.map(b=>e.jsx(M,{value:b.id,children:b.label??b.id},b.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:t("logs.filters.endpoint")}),e.jsxs(te,{value:g,onValueChange:n,children:[e.jsx(se,{children:e.jsx(le,{})}),e.jsxs(ae,{children:[e.jsx(M,{value:"all",children:t("logs.filters.endpointAll")}),e.jsx(M,{value:"anthropic",children:t("logs.filters.endpointAnthropic")}),e.jsx(M,{value:"openai",children:t("logs.filters.endpointOpenAI")}),J==null?void 0:J.map(b=>e.jsx(M,{value:b.id,children:b.label||b.id},b.id))]})]})]}),e.jsx(kt,{className:"md:col-span-2",apiKeys:G,selected:a,disabled:ie,onChange:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:t("logs.filters.modelId")}),e.jsx(xe,{value:N,onChange:b=>u(b.target.value),placeholder:t("logs.filters.modelPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:t("logs.filters.status")}),e.jsxs(te,{value:E,onValueChange:b=>k(b),children:[e.jsx(se,{children:e.jsx(le,{})}),e.jsxs(ae,{children:[e.jsx(M,{value:"all",children:t("logs.filters.statusAll")}),e.jsx(M,{value:"success",children:t("logs.filters.statusSuccess")}),e.jsx(M,{value:"error",children:t("logs.filters.statusError")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:t("logs.filters.startDate")}),e.jsx(xe,{type:"date",value:C,onChange:b=>F(b.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:t("logs.filters.endDate")}),e.jsx(xe,{type:"date",value:w,onChange:b=>L(b.target.value)})]})]})]})})}function ge({label:l,value:t}){return e.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-border/60 bg-card/92 px-2.5 py-1 text-[11px] text-muted-foreground shadow-[0_10px_24px_-22px_rgba(15,23,42,0.28)]",children:[e.jsx("span",{children:l}),e.jsx("span",{className:"metric-number font-semibold text-foreground",children:t})]})}const he={listRequest(l){return{url:"/api/logs",method:"GET",params:l}},detailRequest(l){return{url:l===null?"":`/api/logs/${l}`,method:"GET"}},async exportArchive(l,t){const d=await rt.post("/api/logs/export",l,{responseType:"blob",timeout:t});return new Blob([d.data],{type:"application/zip"})}};function Ct({apiKeyMap:l,logId:t,open:d,providerLabelMap:r}){var n;const{t:c}=P(),{pushToast:s}=fe(),o=B(V.logs.detail(t),he.detailRequest(t),{enabled:d&&t!==null,staleTime:3e4,gcTime:15e3,placeholderData:void 0});m.useEffect(()=>{!o.isError||!o.error||s({title:c("logs.detail.loadError"),description:o.error.message,variant:"error"})},[o.error,o.isError,s,c]);const h=m.useCallback(async(a,i,N)=>{if(!i){s({title:c("logs.detail.copy.empty",{label:a}),variant:"info"});return}try{await xt(i),s({title:c(N),variant:"success"})}catch(u){s({title:c("logs.detail.copy.failure"),description:u instanceof Error?u.message:c("logs.detail.copy.failureFallback"),variant:"error"})}},[s,c]),x=o.data,f=x?r.get(x.provider)??x.provider:"",y=x&&x.api_key_id!=null?l.get(x.api_key_id):void 0,g=x?Fe(x,c):null;return{apiKeyMeta:y,errorMessage:o.isError?((n=o.error)==null?void 0:n.message)??null:null,handleCopy:h,isError:o.isError,isPending:o.isPending,providerLabel:f,refetch:o.refetch,record:x,statusMeta:g}}function _t({open:l,logId:t,onClose:d,providerLabelMap:r,apiKeyMap:c}){var u,E;const{t:s}=P(),{apiKeyMeta:o,errorMessage:h,handleCopy:x,isError:f,isPending:y,providerLabel:g,refetch:n,record:a,statusMeta:i}=Ct({apiKeyMap:c,logId:t,open:l,providerLabelMap:r}),N=m.useMemo(()=>{var C,F,w,L;return a?[{key:"client-request",title:s("logs.detail.payload.clientRequest"),value:((C=a.payload)==null?void 0:C.client_request)??null,emptyLabel:s("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"},...(F=a.payload)!=null&&F.upstream_request?[{key:"upstream-request",title:s("logs.detail.payload.upstreamRequest"),value:a.payload.upstream_request,emptyLabel:s("logs.detail.payload.emptyRequest"),copyToast:"logs.detail.copy.requestSuccess"}]:[],...(w=a.payload)!=null&&w.upstream_response?[{key:"upstream-response",title:s("logs.detail.payload.upstreamResponse"),value:a.payload.upstream_response,emptyLabel:s("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}]:[],{key:"client-response",title:s("logs.detail.payload.clientResponse"),value:((L=a.payload)==null?void 0:L.client_response)??null,emptyLabel:s("logs.detail.payload.emptyResponse"),copyToast:"logs.detail.copy.responseSuccess"}].map(S=>({...S,displayValue:gt(S.value,S.emptyLabel)})):[]},[a,s]);return e.jsx(it,{open:l,onOpenChange:k=>{k||d()},children:e.jsxs(nt,{className:"w-[min(96vw,1200px)] max-w-[1200px]",children:[e.jsxs(dt,{className:"pr-14",children:[e.jsx(ct,{children:s("logs.detail.title")}),e.jsx(pt,{children:a?s("logs.detail.id",{id:a.id}):s("logs.detail.loadError")})]}),e.jsx(ut,{className:"max-h-[78vh]",children:y?e.jsx(mt,{compact:!0,className:"min-h-[240px]",label:s("common.loading")}):f?e.jsx(re,{compact:!0,className:"min-h-[240px]",tone:"danger",title:s("logs.detail.loadError"),description:h??s("common.unknownError"),action:e.jsx(_,{variant:"outline",onClick:()=>void n(),children:s("common.actions.refresh")})}):a?e.jsxs("div",{className:"space-y-6 text-sm",children:[e.jsxs("section",{className:"space-y-4 rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("logs.detail.infoSection")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border bg-secondary p-3 text-xs",children:[e.jsx("span",{className:"font-medium",children:s("logs.detail.summary.route",{from:a.client_model??s("logs.detail.info.noRequestedModel"),to:a.model})}),e.jsx("span",{className:"text-muted-foreground",children:s("logs.detail.summary.latency",{value:q(a.latency_ms,s("common.units.ms"))})}),a.ttft_ms!==null?e.jsxs("span",{className:"text-muted-foreground",children:["TTFT: ",q(a.ttft_ms,s("common.units.ms"))]}):null]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(A,{variant:i==null?void 0:i.variant,children:(i==null?void 0:i.label)??"-"}),e.jsx(A,{variant:"outline",children:a.stream?s("logs.stream.streaming"):s("logs.stream.single")})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsx(O,{label:s("logs.detail.info.latency"),value:q(a.latency_ms,s("common.units.ms"))}),e.jsx(O,{label:s("logs.detail.info.ttft"),value:q(a.ttft_ms,s("common.units.ms"))}),e.jsx(O,{label:s("logs.detail.info.tpot"),value:q(a.tpot_ms,s("common.units.msPerToken"))}),e.jsx(O,{label:s("logs.detail.info.status"),value:(i==null?void 0:i.label)??"-"})]}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsx(R,{label:s("logs.detail.info.time"),value:Te(a.timestamp)}),e.jsx(R,{label:s("logs.detail.info.sessionId"),value:a.session_id??"-"}),e.jsx(R,{label:s("logs.detail.info.endpoint"),value:a.endpoint||"-"}),e.jsx(R,{label:s("logs.detail.info.provider"),value:g}),e.jsx(R,{label:s("logs.detail.info.requestedModel"),value:a.client_model??s("logs.detail.info.noRequestedModel")}),e.jsx(R,{label:s("logs.detail.info.model"),value:a.model}),e.jsx(R,{label:s("logs.detail.info.stream"),value:ft(a.stream)}),e.jsx(R,{label:s("logs.detail.info.status"),value:(i==null?void 0:i.label)??"-"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(O,{label:s("logs.detail.info.inputTokens"),value:Q(a.input_tokens)}),e.jsx(O,{label:s("logs.detail.info.cacheReadTokens"),value:Q(a.cache_read_tokens)}),e.jsx(O,{label:s("logs.detail.info.cacheCreationTokens"),value:Q(a.cache_creation_tokens)}),e.jsx(O,{label:s("logs.detail.info.outputTokens"),value:Q(a.output_tokens)})]}),a.error?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("logs.detail.info.error")}),e.jsx("p",{className:"rounded-xl border border-destructive/50 bg-destructive/10 p-3 text-xs text-destructive",children:a.error})]}):null]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs("section",{className:"space-y-3 rounded-lg border bg-card p-4",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("logs.detail.apiKey.title")}),e.jsxs("dl",{className:"grid gap-x-4 gap-y-3 sm:grid-cols-2",children:[e.jsx(R,{label:s("logs.detail.apiKey.name"),value:a.api_key_id==null&&!a.api_key_name?s("logs.detail.apiKey.missing"):o!=null&&o.isWildcard?s("apiKeys.wildcard"):(o==null?void 0:o.name)??a.api_key_name??s("logs.detail.apiKey.missing")}),e.jsx(R,{label:s("logs.detail.apiKey.identifier"),value:a.api_key_id??s("common.noData")}),e.jsx(R,{label:s("logs.detail.apiKey.masked"),value:o!=null&&o.isWildcard?s("apiKeys.wildcard"):(o==null?void 0:o.maskedKey)??a.api_key_name??s("logs.detail.apiKey.maskedUnavailable")}),e.jsx(R,{label:s("logs.detail.apiKey.lastUsed"),value:o!=null&&o.lastUsedAt?new Date(o.lastUsedAt).toLocaleString():s("common.noData")})]}),e.jsxs("div",{className:"rounded-lg border bg-secondary p-3 text-xs",children:[e.jsx("p",{className:"font-medium",children:s("logs.detail.apiKey.rawMasked")}),e.jsx("p",{className:"mt-1 break-all font-mono",children:a.api_key_value_available?a.api_key_value_masked??s("logs.detail.apiKey.rawUnavailable"):s("logs.detail.apiKey.rawUnavailable")}),e.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:s("logs.detail.apiKey.rawMaskedHint")})]})]}),e.jsxs("section",{className:"space-y-4 rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("logs.detail.payload.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(u=a.payload)!=null&&u.upstream_request||(E=a.payload)!=null&&E.upstream_response?s("logs.detail.payload.helperWithUpstream"):s("logs.detail.payload.helperClientOnly")})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:N.map(k=>e.jsx(Et,{title:k.title,value:k.value,displayValue:k.displayValue,onCopy:()=>x(k.title,k.value,k.copyToast),t:s},k.key))})]})]})]}):e.jsx(re,{compact:!0,className:"min-h-[240px]",title:s("logs.detail.loadError"),description:s("common.noData")})})]})})}function O({label:l,value:t}){return e.jsxs("div",{className:"min-w-0 rounded-lg border bg-secondary px-3 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:l}),e.jsx("p",{className:"mt-2 break-all text-sm font-semibold leading-6",children:t})]})}function R({label:l,value:t}){return e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:l}),e.jsx("dd",{className:"min-w-0 break-all whitespace-pre-wrap text-sm font-medium leading-6 text-foreground",children:t??"-"})]})}function Et({displayValue:l,onCopy:t,title:d,value:r,t:c}){return e.jsxs("div",{className:"space-y-3 rounded-lg border bg-secondary/40 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d}),e.jsx(_,{variant:"outline",size:"sm",onClick:t,children:c("common.actions.copy")})]}),e.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap rounded-lg border bg-secondary p-3 text-xs",children:l})]})}const W=[20,50,100],$=["endpoint","provider","requestedModel","routedModel","apiKey","inputTokens","cacheReadTokens","cacheCreationTokens","outputTokens","latency","ttft","tpot","status","error"],oe=["endpoint","provider","requestedModel","routedModel","apiKey","inputTokens","cacheReadTokens","cacheCreationTokens","outputTokens","latency","ttft","tpot","status","error"];function Dt(){if(typeof window>"u")return $;try{const l=window.localStorage.getItem(D.logs.visibleColumns);if(!l)return $;const t=JSON.parse(l);if(!Array.isArray(t))return $;const d=t.filter(r=>oe.includes(r));return d.length>0?d:$}catch{return $}}function Ft(){return typeof window>"u"?"comfortable":window.localStorage.getItem(D.logs.density)==="compact"?"compact":"comfortable"}function Tt(){if(typeof window>"u")return W[0];const l=window.localStorage.getItem(D.logs.pageSize),t=Number(l);return W.includes(t)?t:W[0]}function Rt(){if(typeof window>"u")return[];try{const l=window.localStorage.getItem(D.logs.selectedApiKeys);if(!l)return[];const t=JSON.parse(l);return Array.isArray(t)?t.map(d=>Number(d)).filter(d=>Number.isInteger(d)&&d>0):[]}catch{return[]}}function _e(l,t=!1){if(!l)return;const d=t?`${l}T23:59:59.999`:`${l}T00:00:00.000`,r=Date.parse(d);return Number.isFinite(r)?r:void 0}function Lt(l,t,d){return l===d&&t===d}function Kt({columnOptions:l,exporting:t,onExport:d,onRefresh:r,onResetColumns:c,onSetDensity:s,onToggleColumn:o,refreshing:h,rowDensity:x,total:f,visibleColumns:y,visibleColumnSet:g}){const{t:n}=P(),a=JSON.stringify(y)===JSON.stringify($);return e.jsxs("div",{className:"flex w-full flex-col gap-3 xl:w-auto xl:flex-row xl:items-center",children:[e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center xl:w-auto xl:flex-nowrap",children:[e.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto rounded-full bg-secondary p-1 sm:w-auto",children:[e.jsx("button",{type:"button",onClick:()=>s("comfortable"),className:j("inline-flex h-8 flex-1 items-center justify-center whitespace-nowrap rounded-full px-3.5 text-xs font-medium transition-all sm:flex-none",x==="comfortable"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:n("logs.table.density.comfortable")}),e.jsx("button",{type:"button",onClick:()=>s("compact"),className:j("inline-flex h-8 flex-1 items-center justify-center whitespace-nowrap rounded-full px-3.5 text-xs font-medium transition-all sm:flex-none",x==="compact"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:n("logs.table.density.compact")})]}),e.jsxs(yt,{children:[e.jsx(bt,{asChild:!0,children:e.jsx(_,{variant:"outline",size:"sm",className:"w-full sm:w-auto",children:n("logs.actions.columns")})}),e.jsxs(jt,{align:"end",className:"w-64 p-3",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:n("logs.actions.columns")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("logs.actions.visibleCount",{count:y.length})})]}),e.jsx(_,{variant:"ghost",size:"sm",onClick:c,disabled:a,children:n("common.actions.reset")})]}),e.jsx("div",{className:"grid gap-1.5",children:l.map(i=>{const N=g.has(i.id);return e.jsxs("label",{className:j("flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2 text-sm transition hover:bg-accent",N&&"bg-primary/10 text-primary"),children:[e.jsx("input",{type:"checkbox",checked:N,onChange:()=>o(i.id),className:"h-4 w-4 rounded border-border"}),e.jsx("span",{children:i.label})]},i.id)})})]})]}),e.jsxs(_,{onClick:d,disabled:t,className:"w-full sm:w-auto",children:[e.jsx(et,{className:"mr-2 h-4 w-4"}),n(t?"logs.actions.exporting":"logs.actions.export")]})]}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-3 xl:w-auto xl:justify-start",children:[e.jsx("span",{className:"text-xs text-muted-foreground sm:text-sm",children:n("logs.summary.total",{value:f.toLocaleString()})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:r,disabled:h,className:"shrink-0",children:[e.jsx(tt,{className:j("mr-2 h-4 w-4",h&&"animate-spin")}),n(h?"common.actions.refreshing":"logs.actions.manualRefresh")]})]})]})}function Mt({record:l,providerLabelMap:t,apiKeyMap:d,onSelect:r,isEven:c,density:s,visibleColumnSet:o}){const{t:h}=P(),x=t.get(l.provider)??l.provider,f=l.endpoint||"-",y=Fe(l,h),g=l.client_model??h("logs.table.requestedModelFallback"),n=l.api_key_id!=null?d.get(l.api_key_id):void 0,a=l.api_key_id==null?h("logs.table.apiKeyUnknown"):n!=null&&n.isWildcard?h("apiKeys.wildcard"):n!=null&&n.name?n.name:l.api_key_name?l.api_key_name:h("logs.table.apiKeyUnknown"),i=s==="compact"?"px-3 py-1.5":"px-3 py-2",N=c?"bg-muted/30":"bg-background",u=ht(l.session_id),E=u==null?void 0:u.rowStyle,k=u==null?void 0:u.stickyStyle,C=u?{...u.stickyStyle,...u.accentStyle}:void 0;return e.jsxs("tr",{"data-session-id":u==null?void 0:u.sessionId,"data-session-color":u==null?void 0:u.colorKey,className:j("transition-colors",u?"":c?"bg-muted/30":"",u?"":"hover:bg-muted/50"),style:E,onMouseEnter:F=>{u&&Object.assign(F.currentTarget.style,u.hoverStyle)},onMouseLeave:F=>{u&&Object.assign(F.currentTarget.style,u.rowStyle)},children:[e.jsx("td",{className:j("sticky left-0 z-10 text-xs",i,u?"":N),style:C,children:Te(l.timestamp)}),o.has("endpoint")&&e.jsx("td",{className:j(i,"text-xs"),children:f}),o.has("provider")&&e.jsx("td",{className:j(i,"text-xs"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:x,children:x})}),o.has("requestedModel")&&e.jsx("td",{className:j(i,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:g,children:g})}),o.has("routedModel")&&e.jsx("td",{className:j(i,"text-xs"),children:e.jsx("div",{className:"max-w-[120px] truncate",title:l.model,children:l.model})}),o.has("apiKey")&&e.jsx("td",{className:j(i,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[90px] truncate",title:a,children:a})}),o.has("inputTokens")&&e.jsx("td",{className:j(i,"text-right text-xs tabular-nums"),children:Q(l.input_tokens)}),o.has("cacheReadTokens")&&e.jsx("td",{className:j(i,"text-right text-xs tabular-nums"),children:Q(l.cache_read_tokens)}),o.has("cacheCreationTokens")&&e.jsx("td",{className:j(i,"text-right text-xs tabular-nums"),children:Q(l.cache_creation_tokens)}),o.has("outputTokens")&&e.jsx("td",{className:j(i,"text-right text-xs tabular-nums"),children:Q(l.output_tokens)}),o.has("latency")&&e.jsx("td",{className:j(i,"text-right text-xs tabular-nums"),children:q(l.latency_ms,"ms")}),o.has("ttft")&&e.jsx("td",{className:j(i,"text-right text-xs tabular-nums"),children:q(l.ttft_ms,"ms")}),o.has("tpot")&&e.jsx("td",{className:j(i,"text-right text-xs tabular-nums"),children:q(l.tpot_ms,"ms/tk")}),o.has("status")&&e.jsx("td",{className:j(i,"text-center"),children:e.jsx(A,{variant:y.variant,className:"text-xs",children:y.label})}),o.has("error")&&e.jsx("td",{className:j(i,"text-xs text-muted-foreground"),children:e.jsx("div",{className:"max-w-[100px] truncate",title:l.error??"",children:l.error?l.error:"-"})}),e.jsx("td",{className:j("sticky right-0 z-10 text-center",i,u?"":N),style:k,children:e.jsx(_,{variant:"outline",size:"sm",onClick:()=>r(l.id),children:h("logs.actions.detail")})})]})}function Pt(l){const{t}=P(),{tableScrollRef:d,visibleColumnSet:r,visibleColumnCount:c,logsError:s,logsPending:o,items:h,activeFiltersCount:x,handleResetFilters:f,handleRetry:y,providerLabelMap:g,apiKeyMap:n,handleOpenDetail:a,rowDensity:i,showScrollHint:N,pageSize:u,setPageSize:E,page:k,totalPages:C,setPage:F}=l;return e.jsx(Ee,{className:"overflow-hidden bg-card shadow-[var(--surface-shadow)]",children:e.jsxs(De,{className:"p-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 bg-secondary/50 px-4 py-3 border-b border-border",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:t("logs.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("logs.actions.visibleCount",{count:c-2})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(A,{variant:"secondary",children:"Wide Table"}),e.jsx(A,{variant:"outline",className:"bg-background",children:t(i==="compact"?"logs.table.density.compact":"logs.table.density.comfortable")}),N?e.jsx(A,{variant:"warning",children:"Scroll for more"}):null]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{ref:d,className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[1480px] text-sm",children:[e.jsx("thead",{className:"border-b border-border/50 bg-secondary/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"sticky left-0 z-20 bg-secondary px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.time")}),r.has("endpoint")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.endpoint")}),r.has("provider")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.provider")}),r.has("requestedModel")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.requestedModel")}),r.has("routedModel")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.routedModel")}),r.has("apiKey")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.apiKey")}),r.has("inputTokens")&&e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.inputTokens")}),r.has("cacheReadTokens")&&e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.cacheReadTokens")}),r.has("cacheCreationTokens")&&e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.cacheCreationTokens")}),r.has("outputTokens")&&e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.outputTokens")}),r.has("latency")&&e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.latency")}),r.has("ttft")&&e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.ttft")}),r.has("tpot")&&e.jsx("th",{className:"px-3 py-2.5 text-right text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.tpot")}),r.has("status")&&e.jsx("th",{className:"px-3 py-2.5 text-center text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.status")}),r.has("error")&&e.jsx("th",{className:"px-3 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.error")}),e.jsx("th",{className:"sticky right-0 z-20 bg-secondary px-3 py-2.5 text-center text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:t("logs.table.columns.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-border/50",children:o?Array.from({length:8}).map((w,L)=>e.jsx(wt,{columns:c},L)):s&&h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:c,className:"px-3 py-6",children:e.jsx(re,{compact:!0,tone:"danger",icon:e.jsx(st,{className:"h-5 w-5","aria-hidden":"true"}),title:t("logs.toast.listError.title"),description:s,action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:y,children:t("common.actions.refresh")}),x>0?e.jsx(_,{variant:"ghost",size:"sm",onClick:f,children:t("common.actions.reset")}):null]})})})}):h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:c,className:"px-3 py-8 text-center text-sm text-muted-foreground",children:e.jsx(re,{compact:!0,tone:"primary",icon:e.jsx(lt,{className:"h-5 w-5","aria-hidden":"true"}),title:x>0?t("logs.empty.filteredTitle"):t("logs.empty.title"),description:x>0?t("logs.empty.filteredSubtitle"):t("logs.empty.subtitle"),action:e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[x>0?e.jsx(_,{variant:"outline",size:"sm",onClick:f,children:t("logs.empty.actions.reset")}):null,e.jsx(_,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx(vt,{to:"/api-keys",children:t("logs.empty.actions.apiKeys")})})]})})})}):h.map((w,L)=>e.jsx(Mt,{record:w,providerLabelMap:g,apiKeyMap:n,onSelect:a,isEven:L%2===0,density:i,visibleColumnSet:r},w.id))})]})}),N&&e.jsx("div",{className:"table-scroll-hint"})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 bg-secondary/50 p-4 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-secondary px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:t("logs.table.pagination.perPage")}),e.jsxs(te,{value:u.toString(),onValueChange:w=>E(Number(w)),children:[e.jsx(se,{className:"h-8 w-[80px] bg-background",children:e.jsx(le,{})}),e.jsx(ae,{children:W.map(w=>e.jsx(M,{value:w.toString(),children:w},w))})]})]}),e.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-secondary px-2 py-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>F(w=>Math.max(w-1,1)),disabled:k<=1,children:t("logs.table.pagination.previous")}),e.jsx("span",{className:"metric-number px-1 text-sm text-muted-foreground",children:t("logs.table.pagination.pageLabel",{page:C===0?0:k,total:C})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>F(w=>C===0?w:Math.min(w+1,C)),disabled:C===0||k>=C,children:t("logs.table.pagination.next")})]})]})]})})}function At({exportTimeoutMs:l,queryParams:t,total:d}){const{t:r}=P(),{pushToast:c}=fe(),[s,o]=m.useState(!1),h=m.useCallback(async()=>{if(!s){o(!0);try{const x=d>0?Math.min(d,5e3):1e3,f={...t,limit:x,offset:0},y=await he.exportArchive(f,l),g=new Date().toISOString().replace(/[:.]/g,"-"),n=URL.createObjectURL(y),a=document.createElement("a");a.href=n,a.download=`cc-gw-logs-${g}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(n),c({title:r("logs.toast.exportSuccess.title"),description:r("logs.toast.exportSuccess.desc"),variant:"success"})}catch(x){const f=ot(x);c({title:r("logs.toast.exportError.title"),description:r("logs.toast.exportError.desc",{message:f.message}),variant:"error"})}finally{o(!1)}}},[l,s,c,t,r,d]);return{exporting:s,handleExport:h}}function zt(){const l=m.useRef(null),[t,d]=m.useState(!1),r=m.useCallback(()=>{const c=l.current;if(!c)return;const s=c.scrollWidth-c.scrollLeft-c.clientWidth>1;d(s)},[]);return m.useEffect(()=>{const c=l.current;if(!c)return;r(),c.addEventListener("scroll",r,{passive:!0});const s=new ResizeObserver(r);return s.observe(c),()=>{c.removeEventListener("scroll",r),s.disconnect()}},[r]),{scrollRef:l,showScrollHint:t,updateScrollHint:r}}function Ot(){const[l,t]=K(D.logs.density,Ft,{serialize:y=>y,deserialize:y=>y==="compact"?"compact":"comfortable"}),[d,r]=K(D.logs.visibleColumns,Dt),{scrollRef:c,showScrollHint:s}=zt(),o=m.useMemo(()=>new Set(d),[d]),h=d.length+2,x=m.useCallback(y=>{r(g=>{if(g.includes(y))return g.length===1?g:g.filter(a=>a!==y);const n=[...g,y];return n.sort((a,i)=>oe.indexOf(a)-oe.indexOf(i)),n})},[]);return{resetVisibleColumns:m.useCallback(()=>{r($)},[]),rowDensity:l,setRowDensity:t,showScrollHint:s,tableScrollRef:c,toggleColumn:x,visibleColumnCount:h,visibleColumns:d,visibleColumnSet:o}}function qt(){var ve,we,Ne,ke,Se;const{t:l}=P(),{pushToast:t}=fe(),d=Nt(),[r,c]=K(D.logs.providerFilter,"all"),[s,o]=K(D.logs.endpointFilter,"all"),[h,x]=K(D.logs.modelFilter,""),[f,y]=K(D.logs.statusFilter,"all"),[g,n]=K(D.logs.fromDate,""),[a,i]=K(D.logs.toDate,""),[N,u]=m.useState(1),[E,k]=K(D.logs.pageSize,Tt,{serialize:p=>String(p),deserialize:p=>{const v=Number(p);return W.includes(v)?v:W[0]}}),[C,F]=m.useState(null),[w,L]=m.useState(!1),[S,G]=K(D.logs.selectedApiKeys,Rt),[ie,J]=K(D.logs.filtersExpanded,!1),{resetVisibleColumns:b,rowDensity:X,setRowDensity:Re,showScrollHint:Le,tableScrollRef:Ke,toggleColumn:Me,visibleColumnCount:Pe,visibleColumns:Ae,visibleColumnSet:ze}=Ot(),Oe=m.useDeferredValue(h),T=h===""?"":Oe;m.useEffect(()=>{u(1)},[r,s,T,f,g,a,E,S]);const ne=m.useMemo(()=>{const p={limit:E,offset:(N-1)*E};r!=="all"&&(p.provider=r),s!=="all"&&(p.endpoint=s),T.trim().length>0&&(p.model=T.trim()),f!=="all"&&(p.status=f);const v=_e(g),I=_e(a,!0);return v!==void 0&&(p.from=v),I!==void 0&&(p.to=I),S.length>0&&(p.apiKeys=S.join(",")),p},[T,s,g,N,E,r,S,f,a]),z=B(V.logs.list(ne),he.listRequest(ne),{gcTime:6e4}),H=B(V.providers.all(),Ce.providersRequest()),ye=B(V.apiKeys.all(),{url:"/api/keys",method:"GET"}),de=B(V.customEndpoints.all(),{url:"/api/custom-endpoints",method:"GET"}),be=B(V.config.exportTimeout(),Ce.configRequest());m.useEffect(()=>{!z.isError||!z.error||t({title:l("logs.toast.listError.title"),description:l("logs.toast.listError.desc",{message:z.error.message}),variant:"error"})},[z.error,z.isError,t,l]),m.useEffect(()=>{!H.isError||!H.error||t({title:l("logs.toast.providerError.title"),description:l("logs.toast.providerError.desc",{message:H.error.message}),variant:"error"})},[H.error,H.isError,t,l]);const ee=((ve=z.data)==null?void 0:ve.total)??0,Z=ee>0?Math.ceil(ee/E):0,qe=((we=z.data)==null?void 0:we.items)??[],Qe=m.useMemo(()=>{var v;const p=(v=be.data)==null?void 0:v.logExportTimeoutSeconds;return typeof p=="number"&&Number.isFinite(p)?Math.min(Math.max(Math.round(p),5),600)*1e3:6e4},[(Ne=be.data)==null?void 0:Ne.logExportTimeoutSeconds]);m.useEffect(()=>{Z>0&&N>Z&&u(Z)},[N,Z]);const ce=H.data??[],pe=m.useMemo(()=>{const p=new Map;for(const v of ce)v.id&&p.set(v.id,v.label??v.id);return p},[ce]),je=m.useMemo(()=>{var v;const p=new Map;p.set("anthropic",l("logs.filters.endpointAnthropic")),p.set("openai",l("logs.filters.endpointOpenAI"));for(const I of((v=de.data)==null?void 0:v.endpoints)??[])p.set(I.id,I.label||I.id);return p},[(ke=de.data)==null?void 0:ke.endpoints,l]),Ie=m.useMemo(()=>{const p=[];if(r!=="all"){const v=pe.get(r)??r;p.push({key:"provider",label:`${l("logs.filters.provider")}: ${v}`,onRemove:()=>c("all")})}if(s!=="all"){const v=je.get(s)??s;p.push({key:"endpoint",label:`${l("logs.filters.endpoint")}: ${v}`,onRemove:()=>o("all")})}if(T.trim()&&p.push({key:"model",label:`${l("logs.filters.modelId")}: ${T.trim()}`,onRemove:()=>x("")}),f!=="all"){const v=l(f==="success"?"logs.filters.statusSuccess":"logs.filters.statusError");p.push({key:"status",label:`${l("logs.filters.status")}: ${v}`,onRemove:()=>y("all")})}return g&&p.push({key:"from",label:`${l("logs.filters.startDate")}: ${g}`,onRemove:()=>n("")}),a&&p.push({key:"to",label:`${l("logs.filters.endDate")}: ${a}`,onRemove:()=>i("")}),S.length>0&&p.push({key:"apiKeys",label:l("logs.filters.apiKeySelected",{count:S.length}),onRemove:()=>G([])}),p},[T,s,je,g,r,pe,S.length,f,l,a]),ue=ye.data??[],Ve=m.useMemo(()=>{const p=new Map;for(const v of ue)p.set(v.id,v);return p},[ue]),Ue=m.useMemo(()=>oe.map(p=>({id:p,label:l(`logs.table.columns.${p}`)})),[l]),Y=m.useMemo(()=>new Date().toISOString().slice(0,10),[]),$e=m.useMemo(()=>r==="all"&&s==="all"&&T.trim()===""&&f==="all"&&g===""&&a===""&&S.length===0?"all":f==="error"&&s==="all"&&r==="all"&&T.trim()===""&&g===""&&a===""&&S.length===0?"errors":Lt(g,a,Y)&&s==="all"&&r==="all"&&T.trim()===""&&f==="all"&&S.length===0?"today":s==="anthropic"&&r==="all"&&T.trim()===""&&f==="all"&&g===""&&a===""&&S.length===0?"anthropic":s==="openai"&&r==="all"&&T.trim()===""&&f==="all"&&g===""&&a===""&&S.length===0?"openai":null,[T,s,g,r,S.length,f,a,Y]),me=m.useCallback(()=>{c("all"),x(""),o("all"),y("all"),n(""),i(""),G([])},[]),He=m.useCallback(p=>{if(u(1),me(),p!=="all"){if(p==="errors"){y("error");return}if(p==="today"){n(Y),i(Y);return}if(p==="anthropic"){o("anthropic");return}p==="openai"&&o("openai")}},[me,Y]),{exporting:Be,handleExport:We}=At({exportTimeoutMs:Qe,queryParams:ne,total:ee}),Ge=m.useCallback(p=>{d.removeQueries({queryKey:["logs","detail"],type:"inactive"}),F(p),L(!0)},[d]),Je=m.useCallback(()=>{L(!1)},[]);return m.useEffect(()=>{w||C===null||(d.removeQueries({queryKey:V.logs.detail(C),exact:!0}),F(null))},[w,d,C]),{activeFilters:Ie,activeQuickView:$e,apiKeyMap:Ve,apiKeys:ue,apiKeysQuery:ye,applyQuickView:He,columnOptions:Ue,customEndpoints:(Se=de.data)==null?void 0:Se.endpoints,endpointFilter:s,exporting:Be,filtersExpanded:ie,fromDate:g,handleCloseDetail:Je,handleExport:We,handleOpenDetail:Ge,handleResetFilters:me,isDetailOpen:w,items:qe,logsQuery:z,modelFilter:h,page:N,pageSize:E,providerFilter:r,providerLabelMap:pe,providerOptions:ce,rowDensity:X,resetVisibleColumns:b,selectedApiKeys:S,selectedLogId:C,setEndpointFilter:o,setFiltersExpanded:J,setFromDate:n,setModelFilter:x,setPage:u,setPageSize:k,setProviderFilter:c,setRowDensity:Re,setSelectedApiKeys:G,setStatusFilter:y,setToDate:i,showScrollHint:Le,statusFilter:f,tableScrollRef:Ke,toDate:a,toggleColumn:Me,total:ee,totalPages:Z,visibleColumnCount:Pe,visibleColumns:Ae,visibleColumnSet:ze}}function ns(){var d;const{t:l}=P(),t=qt();return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(at,{info:t.total>0?e.jsx("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:l("logs.summary.total",{value:t.total.toLocaleString()})}):null,actions:e.jsx(Kt,{columnOptions:t.columnOptions,exporting:t.exporting,onExport:()=>void t.handleExport(),onRefresh:()=>void t.logsQuery.refetch(),onResetColumns:t.resetVisibleColumns,onSetDensity:t.setRowDensity,onToggleColumn:t.toggleColumn,refreshing:t.logsQuery.isFetching,rowDensity:t.rowDensity,total:t.total,visibleColumns:t.visibleColumns,visibleColumnSet:t.visibleColumnSet})}),e.jsx(St,{total:t.total,activeFilters:t.activeFilters,filtersExpanded:t.filtersExpanded,setFiltersExpanded:t.setFiltersExpanded,handleResetFilters:t.handleResetFilters,activeQuickView:t.activeQuickView,applyQuickView:t.applyQuickView,providerFilter:t.providerFilter,setProviderFilter:t.setProviderFilter,endpointFilter:t.endpointFilter,setEndpointFilter:t.setEndpointFilter,selectedApiKeys:t.selectedApiKeys,setSelectedApiKeys:t.setSelectedApiKeys,modelFilter:t.modelFilter,setModelFilter:t.setModelFilter,statusFilter:t.statusFilter,setStatusFilter:t.setStatusFilter,fromDate:t.fromDate,setFromDate:t.setFromDate,toDate:t.toDate,setToDate:t.setToDate,providerOptions:t.providerOptions,apiKeys:t.apiKeys,apiKeysLoading:t.apiKeysQuery.isLoading,customEndpoints:t.customEndpoints}),e.jsx(Pt,{tableScrollRef:t.tableScrollRef,visibleColumnSet:t.visibleColumnSet,visibleColumnCount:t.visibleColumnCount,logsError:t.logsQuery.isError?((d=t.logsQuery.error)==null?void 0:d.message)??null:null,logsPending:t.logsQuery.isPending,items:t.items,activeFiltersCount:t.activeFilters.length,handleResetFilters:t.handleResetFilters,handleRetry:()=>void t.logsQuery.refetch(),providerLabelMap:t.providerLabelMap,apiKeyMap:t.apiKeyMap,handleOpenDetail:t.handleOpenDetail,rowDensity:t.rowDensity,showScrollHint:t.showScrollHint,pageSize:t.pageSize,setPageSize:t.setPageSize,page:t.page,totalPages:t.totalPages,setPage:t.setPage}),e.jsx(_t,{open:t.isDetailOpen,logId:t.selectedLogId,onClose:t.handleCloseDetail,providerLabelMap:t.providerLabelMap,apiKeyMap:t.apiKeyMap})]})}export{ns as default};
@@ -0,0 +1 @@
1
+ import{j as e,aA as ge,aF as be,aG as ve,N as je,r as b,ac as ye}from"./vendor-DdPBfMMb.js";import{L as Ne}from"./router-D2Fb4U0L.js";import{C as we}from"./ConfirmDialog-D7vLTReM.js";import{P as ke}from"./PageToolbar-BxRZF-QJ.js";import{B as h}from"./app-DkubSF6m.js";import{D as W,A as J,a as Z,b as $,c as ee,d as re,e as se}from"./DialogShell-BWia_d99.js";import{u as A}from"./i18n-C8tBby0x.js";import{B as ae}from"./queryKeys-BpeJfcg0.js";import{C as te,a as de}from"./card-Bx5Pg_wP.js";import{I as M}from"./input-b5NRkUKN.js";import{L as D}from"./label-DUoPO5Jo.js";import{S as Me}from"./switch-BDc99Vsq.js";import{u as De}from"./useModelManagementState-Vvv4fzeh.js";import{c as Ce}from"./global-D8DuA4wF.js";import"./query-QCek5MsK.js";import"./radix-CtQBp6Ie.js";import"./gateway-DOu5TM82.js";import"./useAppMutation-CYWYOsqL.js";import"./useApiQuery-4gJC8RZB.js";function Pe({open:l,provider:s,onClose:n,onEdit:f}){const{t:x}=A();return s?e.jsx(W,{open:l,onOpenChange:v=>!v&&n(),children:e.jsxs(J,{className:"max-w-md",children:[e.jsxs(Z,{children:[e.jsx($,{children:x("providers.noModelDialog.title")}),e.jsx(ee,{children:x("providers.noModelDialog.subtitle",{name:s.label||s.id})})]}),e.jsxs(re,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-xl bg-accent p-4 text-sm text-primary",children:x("providers.noModelDialog.description")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x("providers.noModelDialog.hint")})]}),e.jsxs(se,{children:[e.jsx(h,{variant:"outline",onClick:n,children:x("common.actions.close")}),e.jsx(h,{onClick:()=>f(s),children:x("providers.noModelDialog.primary")})]})]})}):null}function Te({providersLength:l,filteredProviders:s,defaultLabels:n,providerSearch:f,providerTypeFilter:x,configPending:v,testingProviderId:a,onOpenEdit:t,onTestConnection:i,onRequestDelete:m,onProviderSearchChange:j,onResetFilters:N}){const{t:g}=A(),S=u=>{const C=u.authMode??(u.type==="anthropic"?"authToken":"apiKey");return C==="authToken"?"Bearer":C==="xAuthToken"?"X-Auth-Token":u.type==="anthropic"?"X-API-Key":g("providers.card.providerDefault")};return e.jsx(te,{className:"rounded-[1.35rem] border border-white/70 bg-card/95 shadow-[0_22px_56px_-46px_rgba(15,23,42,0.24)]",children:e.jsxs(de,{className:"space-y-4 p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 rounded-[1.1rem] bg-secondary/60 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(M,{value:f,onChange:u=>j(u.target.value),placeholder:g("providers.filters.searchPlaceholder"),className:"h-10 bg-card/90 sm:max-w-[520px]"})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ae,{variant:"secondary",className:"rounded-full px-3 py-1 text-xs",children:g("providers.count",{count:s.length})}),e.jsx(h,{variant:"ghost",size:"sm",onClick:N,disabled:!f.trim()&&x==="all",className:"h-8 rounded-full px-3 text-xs",children:g("common.actions.reset")})]})]}),v?e.jsx("div",{className:"flex min-h-[200px] items-center justify-center rounded-lg bg-secondary text-sm text-muted-foreground",children:g("common.loading")}):l===0?e.jsxs("div",{className:"rounded-lg border-2 border-dashed border-border/30 p-12 text-center text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium",children:g("providers.emptyState")}),e.jsx("p",{className:"mt-2 text-xs",children:g("providers.emptyStateSub",{default:"点击上方按钮添加您的第一个提供商"})})]}):s.length===0?e.jsx("div",{className:"rounded-lg border-2 border-dashed border-border/30 p-12 text-center text-sm text-muted-foreground",children:e.jsx("p",{className:"font-medium",children:g("providers.emptyFiltered")})}):e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"grid gap-2.5 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",children:s.map(u=>{var y;const C=S(u),P=((y=u.models)==null?void 0:y.length)??0,T=n.get(u.id);return e.jsx(Ue,{provider:u,authMode:C,modelCount:P,defaultModel:T,isTesting:a===u.id,onEdit:()=>t(u),onTest:()=>i(u),onDelete:()=>m(u),t:g},u.id)})})})]})})}function Ue({provider:l,authMode:s,modelCount:n,defaultModel:f,isTesting:x,onEdit:v,onTest:a,onDelete:t,t:i}){const m=!!f,j=m?"success":"warning",N=i(m?"providers.status.ready":"providers.status.needsDefault");return e.jsx(te,{"data-testid":"provider-card",className:"overflow-hidden rounded-[1rem] border border-border/60 bg-[linear-gradient(180deg,rgba(255,255,255,0.97)_0%,rgba(250,251,253,0.94)_100%)] shadow-[0_14px_32px_-30px_rgba(15,23,42,0.2)] transition-all duration-200 hover:-translate-y-0.5 hover:shadow-[0_20px_38px_-32px_rgba(59,130,246,0.18)] dark:border-white/10 dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.92)_0%,rgba(2,6,23,0.88)_100%)]",children:e.jsxs(de,{className:"space-y-2.5 p-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2.5",children:e.jsx("h3",{className:"truncate text-[14px] font-semibold tracking-[-0.02em] text-foreground",title:l.label||l.id,children:l.label||l.id})}),e.jsx("code",{className:"mt-0.5 block truncate text-[11px] text-muted-foreground",title:l.id,children:l.id})]}),e.jsx(ae,{variant:j,className:"shrink-0 rounded-full px-2 py-0.5 text-[10px]",children:N})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5 text-[11px]",children:[e.jsx(Q,{icon:e.jsx(ge,{className:"h-3.5 w-3.5"}),label:i("providers.card.authMode"),value:s}),e.jsx(Q,{icon:e.jsx(be,{className:"h-3.5 w-3.5"}),label:i("providers.card.modelsTitle"),value:n>0?i("providers.card.modelCount",{count:n}):i("providers.card.passthrough")})]}),e.jsxs("div",{className:"space-y-1.5 rounded-[0.85rem] bg-secondary/45 p-2 shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] dark:bg-slate-900/[0.42]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("code",{className:"truncate",title:l.baseUrl,children:l.baseUrl})]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground/70",children:i("providers.card.defaultModelLabel")}),f?e.jsx("code",{className:"min-w-0 truncate rounded-full border border-border/65 bg-background/82 px-2 py-0.5 text-[10px] text-foreground dark:border-white/10 dark:bg-slate-950/[0.58]",title:f,children:f}):e.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:i("providers.card.noDefault")})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1 border-t border-border/45 pt-2",children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:v,className:"h-7 rounded-full px-2 text-[11px]",children:i("providers.actions.edit")}),e.jsx(h,{variant:"ghost",size:"sm",onClick:a,disabled:x,className:"h-7 rounded-full px-2 text-[11px]",children:x?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"mr-1 h-3 w-3 animate-spin"}),i("common.actions.testingConnection")]}):i("providers.actions.test")}),e.jsx(h,{variant:"ghost",size:"sm",onClick:t,className:"h-7 rounded-full px-2 text-[11px] text-destructive hover:bg-destructive/10 hover:text-destructive",children:i("providers.actions.delete")})]})]})})}function Q({icon:l,label:s,value:n}){return e.jsxs("div",{className:"min-w-0 rounded-[0.75rem] bg-secondary/55 px-2 py-1.5 shadow-[inset_0_1px_0_rgba(255,255,255,0.58)] dark:bg-slate-900/[0.5]",children:[e.jsxs("div",{className:"mb-0.5 flex min-w-0 items-center gap-1.5 text-[10px] font-medium text-muted-foreground",children:[l,e.jsx("span",{className:"truncate",children:s})]}),e.jsx("p",{className:"truncate text-[11px] font-medium text-foreground",title:n,children:n})]})}function Ae({open:l,provider:s,options:n,usePreset:f,preservedExtras:x,onPresetChange:v,onConfirm:a,onClose:t}){const{t:i}=A();return s?e.jsx(W,{open:l,onOpenChange:m=>!m&&t(),children:e.jsxs(J,{className:"max-w-2xl",children:[e.jsxs(Z,{children:[e.jsx($,{children:i("providers.testDialog.title")}),e.jsx(ee,{children:i("providers.testDialog.subtitle",{name:s.label||s.id})})]}),e.jsxs(re,{className:"space-y-4",children:[e.jsx("div",{className:"rounded-xl bg-accent p-4 text-sm text-primary",children:i("providers.testDialog.description")}),e.jsxs("div",{className:"space-y-4 rounded-xl bg-secondary/50 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"provider-test-preset",children:i("providers.testDialog.presetLabel")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("providers.testDialog.presetDescription")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Me,{id:"provider-test-preset",checked:f,onCheckedChange:v})})]}),f?e.jsx("div",{className:"space-y-2",children:e.jsxs("details",{className:"rounded-xl border border-transparent bg-card p-2 text-xs shadow-[var(--surface-shadow)]",children:[e.jsx("summary",{className:"cursor-pointer text-primary hover:underline",children:i("providers.testDialog.presetPreviewSummary")}),e.jsx("div",{className:"mt-2 space-y-1",children:n.map(m=>e.jsxs("code",{className:"block rounded-lg bg-secondary px-2 py-1 text-xs",children:[m.key,": ",m.value]},m.key))})]})}):e.jsx("p",{className:"text-xs text-muted-foreground",children:i("providers.testDialog.presetDescription")})]}),Object.keys(x).length>0&&e.jsxs("div",{className:"space-y-2 rounded-xl bg-secondary/50 p-4 text-xs",children:[e.jsx("p",{className:"font-medium",children:i("providers.testDialog.preservedInfo")}),Object.entries(x).map(([m,j])=>e.jsxs("code",{className:"block rounded-lg border border-transparent bg-card px-2 py-1 shadow-[var(--surface-shadow)]",children:[m,": ",j]},m))]})]}),e.jsxs(se,{children:[e.jsx(h,{variant:"outline",onClick:t,children:i("providers.testDialog.cancel")}),e.jsx(h,{onClick:()=>void a(),children:i("providers.testDialog.primary")})]})]})}):null}function F(){return typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID=="function"?globalThis.crypto.randomUUID():Math.random().toString(36).slice(2,10)}function Se(){return{_key:F(),id:"",label:""}}const I={openai:{baseUrl:"https://api.openai.com/v1"},deepseek:{baseUrl:"https://api.deepseek.com/v1"},huawei:{baseUrl:"https://api.modelarts-maas.com/v1"},kimi:{baseUrl:"https://api.moonshot.cn/v1"},anthropic:{baseUrl:"https://api.anthropic.com/v1"},custom:{}},V=[{value:"openai",label:"OpenAI"},{value:"deepseek",label:"DeepSeek"},{value:"huawei",label:"Huawei Cloud"},{value:"kimi",label:"Kimi"},{value:"anthropic",label:"Anthropic"},{value:"custom",label:"Custom"}];function E(l){return l==="anthropic"?"authToken":"apiKey"}function Y(l){return l?{id:l.id,label:l.label??l.id,baseUrl:l.baseUrl,apiKey:l.apiKey??"",type:l.type??"custom",defaultModel:l.defaultModel??"",models:(l.models??[]).map(s=>({...s,_key:F()})),authMode:l.authMode??E(l.type??"custom")}:{id:"",label:"",baseUrl:"",apiKey:"",type:"custom",defaultModel:"",models:[],authMode:E("custom")}}function _e(l){return{_key:F(),id:l.id,label:l.label}}function Ie({open:l,mode:s,provider:n,existingProviderIds:f,onClose:x,onSubmit:v}){const{t:a}=A(),[t,i]=b.useState(()=>Y(n)),[m,j]=b.useState({}),[N,g]=b.useState(!1),[S,u]=b.useState(null),C=b.useRef(null),P=b.useRef(null),T=b.useRef(null),[y,z]=b.useState(s==="edit");b.useEffect(()=>{l&&(i(Y(n)),j({}),u(null),g(!1),z(s==="edit"))},[l,n,s]),b.useEffect(()=>{if(!l)return;const r=d=>{d.key==="Escape"&&x()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[l,x]),b.useEffect(()=>{if(l){if(s==="create"&&T.current){T.current.focus();return}P.current&&P.current.focus()}},[l,s]);const L=s==="create",K=b.useMemo(()=>t.models.filter(r=>r.id.trim().length>0),[t.models]),H=b.useMemo(()=>{var r;return((r=V.find(d=>d.value===t.type))==null?void 0:r.label)??"Custom"},[t.type]),q=(r,d)=>a(d==="authToken"?"providers.drawer.fields.authModeAuthToken":d==="xAuthToken"?"providers.drawer.fields.authModeXAuthToken":r==="anthropic"?"providers.drawer.fields.authModeApiKey":"providers.drawer.fields.authModeProviderDefault"),le=t.label.trim()||t.id.trim()||a("providers.drawer.summary.untitled"),X=b.useMemo(()=>[{label:a("providers.drawer.summary.type"),value:H},{label:a("providers.drawer.summary.auth"),value:q(t.type,t.authMode)},{label:a("providers.drawer.summary.models"),value:K.length.toLocaleString()}],[K.length,t.authMode,t.type,H,a]),O=r=>d=>{i(c=>({...c,[r]:d}))},ie=r=>{i(d=>{const o=!y||d.label.trim().length===0||d.label===d.id?r:d.label;return{...d,id:r,label:o}})},oe=r=>{i(d=>{var G;const o=I[r??"custom"]??I.custom,p=E(d.type),w=E(r),k=Object.values(I).map(U=>U.baseUrl).filter(U=>!!U),B=!d.baseUrl||k.includes(d.baseUrl),fe=s==="create"&&(d.models.length===0||d.models.every(U=>U.id.trim().length===0)),_={...d,type:r,authMode:d.authMode===p?w:d.authMode};return o!=null&&o.baseUrl&&B&&(_.baseUrl=o.baseUrl),o!=null&&o.models&&fe&&(_.models=o.models.map(_e),_.defaultModel=o.defaultModel??((G=o.models[0])==null?void 0:G.id)??""),_})},ne=(r,d)=>{i(c=>{const o=[...c.models];return o[r]={...o[r],...d},{...c,models:o}})},ce=(r,d)=>{i(c=>{const o=[...c.models],p=o[r];if(!p)return c;const w=!y||!p.label||p.label===p.id,k={...p,id:d,label:w?d:p.label};o[r]=k;const B=c.defaultModel===p.id?d:c.defaultModel;return{...c,models:o,defaultModel:B}})},me=r=>{i(d=>{if(r<0||r>=d.models.length)return d;const c=d.models.filter((p,w)=>w!==r);let o=d.defaultModel;return c.some(p=>p.id===o)||(o=""),{...d,models:c,defaultModel:o}})},xe=()=>{i(r=>({...r,models:[...r.models,Se()]}))},R=r=>{i(d=>({...d,authMode:r}))},ue=()=>{const r={},d=t.id.trim(),c=t.baseUrl.trim();if(s==="create"&&(d.length===0?r.id=a("providers.drawer.errors.idRequired"):f.includes(d)&&(r.id=a("providers.drawer.errors.idDuplicate"))),s==="edit"&&d.length===0&&(r.id=a("providers.drawer.errors.idRequired")),c.length===0)r.baseUrl=a("providers.drawer.errors.baseUrlInvalid");else try{new URL(c)}catch{r.baseUrl=a("providers.drawer.errors.baseUrlInvalid")}if(t.models.length>0){const o=new Set;t.models.some(w=>{const k=w.id.trim();return k.length===0||o.has(k)?!0:(o.add(k),!1)})&&(r.models=a("providers.drawer.errors.modelInvalid"))}return t.defaultModel&&!t.models.some(o=>o.id===t.defaultModel)&&(r.models=a("providers.drawer.errors.defaultInvalid")),j(r),Object.keys(r).length===0},pe=()=>{const r=t.models.map(o=>{var p;return{id:o.id.trim(),label:(p=o.label)!=null&&p.trim()?o.label.trim():void 0}}).filter(o=>o.id.length>0),d=n!=null&&n.extraHeaders&&Object.keys(n.extraHeaders).length>0?n.extraHeaders:void 0,c=t.authMode==="apiKey"&&t.type!=="anthropic"?void 0:t.authMode;return{id:t.id.trim(),label:t.label.trim()||t.id.trim(),baseUrl:t.baseUrl.trim(),apiKey:t.apiKey.trim()||void 0,type:t.type??"custom",defaultModel:t.defaultModel||void 0,models:r.length>0?r:void 0,extraHeaders:d,authMode:c}},he=async()=>{if(u(null),!!ue()){g(!0);try{const r=pe();await v(r)}catch(r){u(a("providers.drawer.toast.saveFailure",{message:r instanceof Error?r.message:"unknown"})),g(!1);return}g(!1),x()}};return l?e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-background/80 backdrop-blur-sm",onClick:x,"aria-hidden":"true"}),e.jsxs("aside",{ref:C,role:"dialog","aria-modal":"true","aria-labelledby":"provider-drawer-title","aria-describedby":"provider-drawer-desc",className:"flex h-full min-h-0 w-full max-w-5xl flex-col border-l border-border/45 bg-background/96 shadow-[var(--surface-shadow-lg)] backdrop-blur",children:[e.jsxs("header",{className:"border-b border-border/45 bg-secondary/45 px-6 py-5 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"inline-flex rounded-full border border-primary/20 bg-primary/10 px-3 py-1 text-[11px] font-medium uppercase tracking-[0.18em] text-primary",children:a(L?"providers.drawer.quickStart":"providers.drawer.editTitle")}),e.jsxs("div",{children:[e.jsx("h2",{id:"provider-drawer-title",className:"text-lg font-semibold tracking-[-0.02em]",children:a(L?"providers.drawer.createTitle":"providers.drawer.editTitle")}),e.jsx("p",{id:"provider-drawer-desc",className:"text-sm text-muted-foreground",children:a("providers.drawer.description")})]})]}),e.jsx(h,{type:"button",ref:P,variant:"outline",onClick:x,className:"bg-card",children:a("common.actions.close")})]}),e.jsx("div",{className:"mt-4 grid gap-3 md:grid-cols-3",children:X.map(r=>e.jsxs("div",{className:"rounded-xl border border-transparent bg-card px-4 py-3 shadow-[var(--surface-shadow)]",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:r.label}),e.jsx("p",{className:"mt-2 text-sm font-semibold text-foreground",children:r.value})]},r.label))})]}),e.jsxs("div",{className:"grid min-h-0 flex-1 overflow-hidden xl:grid-cols-[minmax(0,1fr)_280px]",children:[e.jsxs("div",{className:"min-h-0 overflow-y-auto px-6 py-5 pb-10",children:[e.jsxs("section",{className:"space-y-5","aria-labelledby":"provider-type-fields",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{id:"provider-type-fields",className:"text-sm font-semibold",children:a("providers.drawer.sections.type")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("providers.drawer.hints.type")})]}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:V.map(r=>{var c;const d=r.value===t.type;return e.jsxs("button",{type:"button",onClick:()=>oe(r.value),className:Ce("rounded-2xl border px-4 py-3 text-left transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",d?"border-primary bg-primary/10 text-primary shadow-sm":"border-border bg-card text-foreground hover:border-primary/20 hover:bg-accent/50"),children:[e.jsx("div",{className:"text-sm font-semibold",children:r.label}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:((c=I[r.value??"custom"])==null?void 0:c.baseUrl)??a("providers.drawer.hints.customProvider")})]},r.value??"custom")})})]}),e.jsxs("section",{className:"mt-8 space-y-4","aria-labelledby":"provider-basic-info",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{id:"provider-basic-info",className:"text-sm font-semibold",children:a("providers.drawer.sections.basic")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("providers.drawer.hints.basic")})]}),e.jsx(h,{type:"button",variant:"outline",size:"sm",onClick:()=>z(r=>!r),className:"bg-card text-xs",children:a(y?"providers.drawer.fields.hideAdvanced":"providers.drawer.fields.showAdvanced")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(D,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:a("providers.drawer.fields.id")}),e.jsx(M,{value:t.id,ref:T,onChange:r=>ie(r.target.value),disabled:!L,placeholder:a("providers.drawer.fields.idPlaceholder"),"aria-invalid":!!m.id}),m.id?e.jsx("span",{className:"text-xs text-destructive",children:m.id}):null]}),e.jsxs(D,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:a("providers.drawer.fields.label")}),e.jsx(M,{value:t.label,onChange:r=>O("label")(r.target.value),placeholder:a("providers.drawer.fields.labelPlaceholder")})]})]}),e.jsxs(D,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:a("providers.drawer.fields.baseUrl")}),e.jsx(M,{value:t.baseUrl,onChange:r=>O("baseUrl")(r.target.value),placeholder:a("providers.drawer.fields.baseUrlPlaceholder"),"aria-invalid":!!m.baseUrl}),m.baseUrl?e.jsx("span",{className:"text-xs text-destructive",children:m.baseUrl}):null]})]}),e.jsxs("section",{className:"mt-8 space-y-4","aria-labelledby":"provider-auth-fields",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{id:"provider-auth-fields",className:"text-sm font-semibold",children:a("providers.drawer.sections.auth")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("providers.drawer.hints.auth")})]}),e.jsxs(D,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:a("providers.drawer.fields.apiKey")}),e.jsx(M,{value:t.apiKey,onChange:r=>O("apiKey")(r.target.value),placeholder:a("providers.drawer.fields.apiKeyPlaceholder")})]}),e.jsxs("fieldset",{className:"grid gap-2 rounded-xl border border-transparent bg-card p-4 text-xs shadow-[var(--surface-shadow)]",children:[e.jsx("legend",{className:"px-1 text-muted-foreground",children:a("providers.drawer.fields.authMode")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:a("providers.drawer.fields.authModeHint")}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-xl border border-transparent px-3 py-2 transition hover:bg-accent focus-within:bg-accent",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"apiKey",checked:t.authMode==="apiKey",onChange:()=>R("apiKey"),className:"mt-0.5 h-4 w-4 accent-[hsl(var(--primary))]"}),e.jsx("span",{children:q(t.type,"apiKey")})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-xl border border-transparent px-3 py-2 transition hover:bg-accent focus-within:bg-accent",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"authToken",checked:t.authMode==="authToken",onChange:()=>R("authToken"),className:"mt-0.5 h-4 w-4 accent-[hsl(var(--primary))]"}),e.jsx("span",{children:a("providers.drawer.fields.authModeAuthToken")})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-xl border border-transparent px-3 py-2 transition hover:bg-accent focus-within:bg-accent",children:[e.jsx("input",{type:"radio",name:"provider-auth-mode",value:"xAuthToken",checked:t.authMode==="xAuthToken",onChange:()=>R("xAuthToken"),className:"mt-0.5 h-4 w-4 accent-[hsl(var(--primary))]"}),e.jsx("span",{children:a("providers.drawer.fields.authModeXAuthToken")})]})]})]}),e.jsxs("section",{className:"mt-8 space-y-4","aria-labelledby":"provider-model-fields",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{id:"provider-model-fields",className:"text-sm font-semibold",children:a("providers.drawer.fields.models")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("providers.drawer.modelsDescription")})]}),e.jsx(h,{type:"button",variant:"outline",size:"sm",onClick:xe,className:"bg-card text-xs",children:a("providers.drawer.fields.addModel")})]}),m.models?e.jsx("p",{className:"text-xs text-destructive",children:m.models}):null,e.jsxs("div",{className:"space-y-4",children:[t.models.map((r,d)=>e.jsxs("div",{className:"rounded-xl border border-transparent bg-card p-4 shadow-[var(--surface-shadow)]",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(D,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:a("providers.drawer.fields.modelId")}),e.jsx(M,{value:r.id,onChange:c=>ce(d,c.target.value),placeholder:a("providers.drawer.fields.modelIdPlaceholder")})]}),y?e.jsxs(D,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:a("providers.drawer.fields.modelLabel")}),e.jsx(M,{value:r.label??"",onChange:c=>ne(d,{label:c.target.value}),placeholder:a("providers.drawer.fields.modelLabelPlaceholder")})]}):null]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3 text-xs",children:[e.jsxs("label",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx("input",{type:"radio",name:"defaultModel",value:r.id,checked:t.defaultModel===r.id,onChange:()=>i(c=>({...c,defaultModel:r.id})),disabled:r.id.trim().length===0,className:"h-4 w-4 accent-[hsl(var(--primary))]"}),a("providers.drawer.fields.setDefault")]}),e.jsx(h,{type:"button",variant:"ghost",size:"sm",className:"h-auto px-2 text-destructive",onClick:()=>me(d),disabled:t.models.length===0,children:a("providers.drawer.fields.removeModel")})]})]},r._key)),t.models.length===0?e.jsx("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-5 dark:border-amber-800 dark:bg-amber-950/30",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:a("providers.drawer.noModelsTitle")}),e.jsx("p",{className:"text-xs leading-relaxed text-amber-800 dark:text-amber-300",children:a("providers.drawer.noModelsHint",{providerId:t.id||"provider-id"})}),e.jsxs("div",{className:"rounded-lg bg-secondary/50 p-2.5",children:[e.jsx("p",{className:"mb-1.5 text-xs font-medium text-foreground",children:a("providers.drawer.routeExample")}),e.jsxs("code",{className:"block rounded-lg border border-transparent bg-card px-2.5 py-1.5 font-mono text-xs text-foreground shadow-[var(--surface-shadow)]",children:['"claude-*": "',(t.id||"provider-id").trim()||"provider-id",':*"']})]})]})}):null]}),K.length>1?e.jsx("div",{className:"text-xs text-muted-foreground",children:a("providers.drawer.defaultHint",{model:t.defaultModel||a("providers.card.noDefault")})}):null]})]}),e.jsx("aside",{className:"hidden min-h-0 overflow-y-auto border-l border-border/45 bg-secondary/40 px-5 py-5 xl:block",children:e.jsxs("div",{className:"sticky top-0 space-y-5",children:[e.jsxs("div",{className:"rounded-xl border border-transparent bg-card p-4 shadow-[var(--surface-shadow)]",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:a("providers.drawer.formSummary")}),e.jsx("p",{className:"mt-2 text-base font-semibold",children:le}),e.jsx("div",{className:"mt-4 space-y-3 text-sm",children:X.map(r=>e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:r.label}),e.jsx("span",{className:"text-right font-medium",children:r.value})]},r.label))})]}),e.jsxs("div",{className:"rounded-xl border border-transparent bg-card p-4 shadow-[var(--surface-shadow)]",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-[0.16em] text-muted-foreground",children:a("providers.drawer.sections.checklist")}),e.jsxs("ul",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("li",{children:a("providers.drawer.hints.checkUrl")}),e.jsx("li",{children:a("providers.drawer.hints.checkAuth")}),e.jsx("li",{children:a("providers.drawer.hints.checkModels")})]})]}),y&&e.jsxs("div",{className:"rounded-xl bg-accent p-4 text-sm text-foreground",children:[e.jsx("p",{className:"font-medium text-primary",children:a("providers.drawer.hints.advancedTitle")}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:a("providers.drawer.hints.advancedBody")})]})]})})]}),e.jsxs("footer",{className:"flex items-center justify-between gap-3 border-t border-border/45 bg-secondary/45 px-6 py-4 text-sm backdrop-blur-sm",children:[e.jsx("div",{className:"flex flex-col text-xs text-destructive","aria-live":"polite",children:S?e.jsx("span",{children:S}):null}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{type:"button",variant:"outline",onClick:x,disabled:N,className:"bg-card",children:a("common.actions.cancel")}),e.jsx(h,{type:"button",onClick:he,disabled:N,children:a(N?"common.actions.saving":"common.actions.save")})]})]})]})]}):null}function er(){const{t:l}=A(),s=De();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ke,{info:e.jsx("span",{className:"rounded-full bg-secondary px-2.5 py-1 text-xs text-muted-foreground",children:l("providers.count",{count:s.providerCount})}),actions:e.jsxs(e.Fragment,{children:[e.jsx(h,{asChild:!0,variant:"outline",size:"sm",children:e.jsxs(Ne,{to:"/routing",children:[l("nav.routing"),e.jsx(ye,{className:"h-4 w-4","aria-hidden":"true"})]})}),e.jsx(h,{size:"sm",onClick:s.handleOpenCreate,children:l("providers.actions.add")})]})}),e.jsx(Te,{configPending:s.configQuery.isPending||!s.config&&s.configQuery.isFetching,defaultLabels:s.defaultLabels,filteredProviders:s.filteredProviders,onOpenEdit:s.handleOpenEdit,onRequestDelete:n=>s.setConfirmAction({kind:"provider",provider:n}),onResetFilters:()=>{s.setProviderSearch(""),s.setProviderTypeFilter("all")},onProviderSearchChange:s.setProviderSearch,onProviderTypeChange:s.setProviderTypeFilter,onTestConnection:s.initiateTestConnection,providerSearch:s.providerSearch,providerTypeFilter:s.providerTypeFilter,providersLength:s.providers.length,testingProviderId:s.testingProviderId}),e.jsx(Ie,{open:s.drawerOpen,mode:s.drawerMode,provider:s.drawerMode==="edit"?s.editingProvider:void 0,existingProviderIds:s.providers.map(n=>n.id).filter(n=>s.drawerMode==="edit"&&s.editingProvider?n!==s.editingProvider.id:!0),onClose:()=>{s.setDrawerOpen(!1),s.setEditingProvider(void 0),s.setDrawerMode("create")},onSubmit:s.handleProviderSubmit}),e.jsx(Ae,{open:s.testDialogOpen,provider:s.testDialogProvider,options:s.anthropicTestHeaderOptions,preservedExtras:s.testDialogPreservedExtras,usePreset:s.testDialogUsePreset,onPresetChange:s.setTestDialogUsePreset,onConfirm:s.confirmTestDialog,onClose:s.closeTestDialog}),e.jsx(Pe,{open:!!s.noModelDialogProvider,provider:s.noModelDialogProvider,onClose:()=>s.setNoModelDialogProvider(null),onEdit:n=>{s.setNoModelDialogProvider(null),s.handleOpenEdit(n)}}),e.jsx(we,{open:!!s.confirmAction,onOpenChange:n=>{!n&&!s.confirmingAction&&s.setConfirmAction(null)},title:s.confirmDialogTitle,description:s.confirmDialogDescription,confirmLabel:s.confirmingAction?l("common.actions.loading"):l("common.delete"),cancelLabel:l("common.actions.cancel"),loading:s.confirmingAction,onConfirm:s.handleConfirmDialog,children:s.confirmDialogName?e.jsx("div",{className:"rounded-xl border border-destructive/20 bg-destructive/5 px-3 py-2 font-mono text-xs text-foreground",children:s.confirmDialogName}):null})]})}export{er as default};
@@ -1 +1 @@
1
- import{j as s}from"./vendor-z22RpOY0.js";import{c as x}from"./global-B-NXh5qD.js";function i({title:r,description:e,eyebrow:a,actions:t,className:d,contentClassName:l,children:c}){const m=r||e||a||t;return s.jsxs("div",{className:x("rounded-[1.35rem] border border-white/70 bg-card/95 shadow-[0_22px_56px_-46px_rgba(15,23,42,0.24)] backdrop-blur",d),children:[m&&s.jsxs("div",{className:"flex flex-col gap-4 p-6 pb-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[a?s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-primary/78",children:a}):null,typeof r=="string"?s.jsx("h2",{className:"text-base font-semibold text-foreground",children:r}):r,e&&(typeof e=="string"?s.jsx("p",{className:"text-sm text-muted-foreground/70",children:e}):s.jsx("div",{className:"text-sm text-muted-foreground/70",children:e}))]}),t&&s.jsx("div",{className:"w-full shrink-0 sm:w-auto",children:t})]}),s.jsx("div",{className:x("p-6",!m&&"pt-6",l),children:c})]})}export{i as P};
1
+ import{j as s}from"./vendor-DdPBfMMb.js";import{c as x}from"./global-D8DuA4wF.js";function i({title:r,description:e,eyebrow:a,actions:t,className:d,contentClassName:l,children:c}){const m=r||e||a||t;return s.jsxs("div",{className:x("rounded-[1.35rem] border border-white/70 bg-card/95 shadow-[0_22px_56px_-46px_rgba(15,23,42,0.24)] backdrop-blur",d),children:[m&&s.jsxs("div",{className:"flex flex-col gap-4 p-6 pb-0 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[a?s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-primary/78",children:a}):null,typeof r=="string"?s.jsx("h2",{className:"text-base font-semibold text-foreground",children:r}):r,e&&(typeof e=="string"?s.jsx("p",{className:"text-sm text-muted-foreground/70",children:e}):s.jsx("div",{className:"text-sm text-muted-foreground/70",children:e}))]}),t&&s.jsx("div",{className:"w-full shrink-0 sm:w-auto",children:t})]}),s.jsx("div",{className:x("p-6",!m&&"pt-6",l),children:c})]})}export{i as P};
@@ -1 +1 @@
1
- import{j as e,N as c}from"./vendor-z22RpOY0.js";import{c as i}from"./global-B-NXh5qD.js";const m={default:"border-border/30 bg-card shadow-sm",primary:"border-primary/10 bg-card shadow-sm",danger:"border-destructive/15 bg-card shadow-sm"},o={default:"bg-secondary text-primary",primary:"bg-primary/10 text-primary",danger:"bg-destructive/10 text-destructive"};function x({icon:r,title:a,description:s,action:t,className:n,compact:l=!1,tone:d="default"}){return e.jsxs("div",{className:i("flex flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 text-center",l?"min-h-[180px] py-8":"min-h-[260px] py-12",m[d],n),children:[r?e.jsx("div",{className:i("mb-4 flex h-12 w-12 items-center justify-center rounded-2xl",o[d]),children:r}):null,e.jsxs("div",{className:"max-w-xl space-y-1.5",children:[e.jsx("div",{className:"text-base font-semibold tracking-[-0.01em]",children:a}),s?e.jsx("div",{className:"text-sm text-muted-foreground",children:s}):null]}),t?e.jsx("div",{className:"mt-5 flex flex-wrap items-center justify-center gap-2",children:t}):null]})}function p({label:r,className:a,compact:s=!1}){return e.jsx(x,{className:a,compact:s,tone:"primary",icon:e.jsx(c,{className:"h-5 w-5 animate-spin","aria-hidden":"true"}),title:r})}export{p as P,x as a};
1
+ import{j as e,N as c}from"./vendor-DdPBfMMb.js";import{c as i}from"./global-D8DuA4wF.js";const m={default:"border-border/30 bg-card shadow-sm",primary:"border-primary/10 bg-card shadow-sm",danger:"border-destructive/15 bg-card shadow-sm"},o={default:"bg-secondary text-primary",primary:"bg-primary/10 text-primary",danger:"bg-destructive/10 text-destructive"};function x({icon:r,title:a,description:s,action:t,className:n,compact:l=!1,tone:d="default"}){return e.jsxs("div",{className:i("flex flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 text-center",l?"min-h-[180px] py-8":"min-h-[260px] py-12",m[d],n),children:[r?e.jsx("div",{className:i("mb-4 flex h-12 w-12 items-center justify-center rounded-2xl",o[d]),children:r}):null,e.jsxs("div",{className:"max-w-xl space-y-1.5",children:[e.jsx("div",{className:"text-base font-semibold tracking-[-0.01em]",children:a}),s?e.jsx("div",{className:"text-sm text-muted-foreground",children:s}):null]}),t?e.jsx("div",{className:"mt-5 flex flex-wrap items-center justify-center gap-2",children:t}):null]})}function p({label:r,className:a,compact:s=!1}){return e.jsx(x,{className:a,compact:s,tone:"primary",icon:e.jsx(c,{className:"h-5 w-5 animate-spin","aria-hidden":"true"}),title:r})}export{p as P,x as a};