@chenpu17/cc-gw 0.8.13 → 0.8.14

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 (54) hide show
  1. package/package.json +5 -5
  2. package/src/web/dist/assets/{About-BtrUwqVl.js → About-pcECYYVj.js} +1 -1
  3. package/src/web/dist/assets/{ApiKeys-BgtU9Z5t.js → ApiKeys-IDt4ZfLj.js} +1 -1
  4. package/src/web/dist/assets/{ConfirmDialog-BHrsB4gR.js → ConfirmDialog-oYHVEpGJ.js} +1 -1
  5. package/src/web/dist/assets/{Dashboard-DIguazuF.js → Dashboard-BiCTswfM.js} +1 -1
  6. package/src/web/dist/assets/{DialogShell-DcG-SXEV.js → DialogShell-DcOGCV8m.js} +1 -1
  7. package/src/web/dist/assets/{Events-mZNIWc7c.js → Events-CCYCOF1f.js} +1 -1
  8. package/src/web/dist/assets/{Help-BHbnZJeo.js → Help-BW1R1cf1.js} +2 -2
  9. package/src/web/dist/assets/{Login-DugtPFxy.js → Login-Dn8fbfFq.js} +1 -1
  10. package/src/web/dist/assets/{Logs-BJBm-efJ.js → Logs-D2FFPpBP.js} +1 -1
  11. package/src/web/dist/assets/{ModelManagement-C32W7nDe.js → ModelManagement-BHSUJ4Dg.js} +1 -1
  12. package/src/web/dist/assets/{PageHeader--Lg_YQVw.js → PageHeader-DCqHI67a.js} +1 -1
  13. package/src/web/dist/assets/{PageSection-DIAhP18t.js → PageSection-CuZMzA0E.js} +1 -1
  14. package/src/web/dist/assets/{PageState-DKba6Ew1.js → PageState-B03H5AV0.js} +1 -1
  15. package/src/web/dist/assets/{Profiler-DTPqRwx7.js → Profiler-CEpu2dMu.js} +1 -1
  16. package/src/web/dist/assets/{RoutingManagement-B9Z0l4LZ.js → RoutingManagement-DahJxjA7.js} +1 -1
  17. package/src/web/dist/assets/{Settings-Ddx0C5eQ.js → Settings-Vp7jGxIW.js} +1 -1
  18. package/src/web/dist/assets/{Skeleton-cyuMRxwQ.js → Skeleton-i1PjWApN.js} +1 -1
  19. package/src/web/dist/assets/{app-BG16DmZH.js → app-COiQeF3y.js} +3 -3
  20. package/src/web/dist/assets/{card-CwTuH2Iq.js → card-ChFVaqLf.js} +1 -1
  21. package/src/web/dist/assets/{charts-core-D9OugzV_.js → charts-core-DzWzxST6.js} +1 -1
  22. package/src/web/dist/assets/{charts-engine-DleyglMn.js → charts-engine-Ds7lwC51.js} +1 -1
  23. package/src/web/dist/assets/{charts-react-BqhUp1x_.js → charts-react-D0nWbUCA.js} +1 -1
  24. package/src/web/dist/assets/{gateway-CExOTXeI.js → gateway-BU3dR2tm.js} +1 -1
  25. package/src/web/dist/assets/{global-CKvMKvrn.js → global-B-NXh5qD.js} +1 -1
  26. package/src/web/dist/assets/global-B_hBylxt.css +1 -0
  27. package/src/web/dist/assets/{i18n-B3N4Df3E.js → i18n-Bl2BcCDG.js} +1 -1
  28. package/src/web/dist/assets/{input-scp9nKJc.js → input-DW7jGTgj.js} +1 -1
  29. package/src/web/dist/assets/{label-fMXEnAEx.js → label-Ci1io7XA.js} +1 -1
  30. package/src/web/dist/assets/landing-BMe5-cHU.js +17 -0
  31. package/src/web/dist/assets/live-en-api-keys-Bx8N-eoh.png +0 -0
  32. package/src/web/dist/assets/live-en-dashboard-CJoX7IQT.png +0 -0
  33. package/src/web/dist/assets/live-en-events-DJwaP-WW.png +0 -0
  34. package/src/web/dist/assets/live-en-logs-BGGL53ab.png +0 -0
  35. package/src/web/dist/assets/live-en-model-management-BpjNblfR.png +0 -0
  36. package/src/web/dist/assets/package-D5lk1iqk.js +1 -0
  37. package/src/web/dist/assets/{popover-BGSWKBlu.js → popover-CQHCVE2z.js} +1 -1
  38. package/src/web/dist/assets/{query-Cpxr1dul.js → query-BbGWgOFk.js} +1 -1
  39. package/src/web/dist/assets/{queryKeys-DTnZc8Yy.js → queryKeys-ucXCzh0P.js} +1 -1
  40. package/src/web/dist/assets/{radix-bG5h1Ymq.js → radix-mHySgtou.js} +1 -1
  41. package/src/web/dist/assets/{router-DspBTS8b.js → router-CL3rf_uf.js} +1 -1
  42. package/src/web/dist/assets/{select-BjYpeVvo.js → select-BchX45jJ.js} +1 -1
  43. package/src/web/dist/assets/{switch-CgwYcn5P.js → switch-CT24uL_Q.js} +1 -1
  44. package/src/web/dist/assets/{table-BtnjYcvG.js → table-DdvG93mx.js} +1 -1
  45. package/src/web/dist/assets/{useApiQuery-jSeDDFuv.js → useApiQuery-tbd4JJaZ.js} +1 -1
  46. package/src/web/dist/assets/{useAppMutation-ChCrgiP6.js → useAppMutation-SONU2xFC.js} +1 -1
  47. package/src/web/dist/assets/useModelManagementState-DcQ0Ac-x.js +1 -0
  48. package/src/web/dist/assets/{vendor-LWJeAdU1.js → vendor-z22RpOY0.js} +86 -66
  49. package/src/web/dist/index.html +8 -8
  50. package/src/web/dist/landing.html +11 -11
  51. package/src/web/dist/assets/global-CUpRxoFd.css +0 -1
  52. package/src/web/dist/assets/landing-CHY6qfgq.js +0 -5
  53. package/src/web/dist/assets/package-BMIMFcQR.js +0 -1
  54. package/src/web/dist/assets/useModelManagementState-9RhvWh8Y.js +0 -1
@@ -1,5 +1,5 @@
1
- import{r as g,j as e,aP as v,aM as f,aQ as k,ac as C}from"./vendor-LWJeAdU1.js";import{P as $}from"./PageHeader--Lg_YQVw.js";import{P as o}from"./PageSection-DIAhP18t.js";import{c as q}from"./clipboard-CALi6bTW.js";import{c as h}from"./global-CKvMKvrn.js";import{C as j,a as b}from"./card-CwTuH2Iq.js";import{B as S}from"./app-BG16DmZH.js";import{u as y}from"./i18n-B3N4Df3E.js";import"./query-Cpxr1dul.js";import"./router-DspBTS8b.js";import"./radix-bG5h1Ymq.js";const P="group rounded-[1rem] border border-white/70 bg-card/95 p-3.5 shadow-[0_18px_42px_-38px_rgba(15,23,42,0.24)] transition hover:-translate-y-0.5 hover:shadow-[0_22px_48px_-40px_rgba(59,130,246,0.18)]";function R(){const{t:s}=y(),t=g.useMemo(()=>{const i=s("help.sections.configuration.items",{returnObjects:!0}),n=s("help.sections.claudeCodeConfig.items",{returnObjects:!0}),r=s("help.sections.codexConfig.items",{returnObjects:!0}),d=s("help.sections.usage.items",{returnObjects:!0}),_=s("help.sections.tips.items",{returnObjects:!0});return[{title:s("help.sections.configuration.title"),items:i},{title:s("help.sections.claudeCodeConfig.title"),items:n},{title:s("help.sections.codexConfig.title"),items:r},{title:s("help.sections.usage.title"),items:d},{title:s("help.sections.tips.title"),items:_}]},[s]),l=s("help.faq.items",{returnObjects:!0}),a=t[0].items.slice(0,3),c=g.useMemo(()=>[{id:"configuration",title:t[0].title,subtitle:p(t[0].items[0]??"")},{id:"claude",title:t[1].title,subtitle:p(t[1].items[0]??"")},{id:"codex",title:t[2].title,subtitle:p(t[2].items[0]??"")},{id:"faq",title:s("help.faq.title"),subtitle:s("help.meta.faqCount",{count:l.length})}],[l.length,t,s]);return e.jsxs("div",{className:"space-y-5",children:[e.jsx($,{icon:e.jsx(v,{className:"h-5 w-5","aria-hidden":"true"}),title:s("help.title"),description:s("help.intro"),breadcrumb:s("help.meta.breadcrumb"),helper:s("help.helper"),badge:s("help.meta.guides",{count:t.length})}),e.jsx(j,{className:"rounded-[1.2rem] border border-white/70 bg-card/95 shadow-[0_20px_50px_-42px_rgba(15,23,42,0.24)] xl:hidden",children:e.jsxs(b,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-[0.95rem] bg-accent text-primary",children:e.jsx(f,{className:"h-4.5 w-4.5","aria-hidden":"true"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:s("help.note")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:s("help.helper")})]})]}),e.jsxs("div",{className:"rounded-[0.95rem] bg-secondary/55 p-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.62)]",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-primary/78",children:s("help.meta.recommendedFlow")}),e.jsx("div",{className:"-mx-1 mt-2 flex gap-2 overflow-x-auto px-1 pb-1",children:c.map(i=>e.jsxs("a",{href:`#help-${i.id}`,className:"w-[190px] shrink-0 rounded-[0.95rem] border border-white/65 bg-background/82 px-3 py-2.5 shadow-[0_10px_24px_-20px_rgba(15,23,42,0.18)]",children:[e.jsx("p",{className:"text-[13px] font-semibold text-foreground",children:i.title}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-4.5 text-muted-foreground",children:i.subtitle})]},i.id))}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:a.map((i,n)=>e.jsxs("span",{className:"inline-flex items-center rounded-full bg-background/78 px-2.5 py-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"mr-1.5 inline-flex h-4.5 w-4.5 items-center justify-center rounded-full bg-primary text-[10px] font-semibold text-primary-foreground",children:n+1}),e.jsx("span",{className:"line-clamp-1",children:p(i)})]},`${n}-${i}`))})]})]})}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[280px_minmax(0,1fr)] xl:items-start",children:[e.jsxs("aside",{className:"hidden space-y-4 xl:sticky xl:top-24 xl:block",children:[e.jsx(j,{className:"rounded-[1.25rem] border border-white/70 bg-card/95 shadow-[0_20px_50px_-42px_rgba(15,23,42,0.24)]",children:e.jsxs(b,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-[1rem] bg-accent text-primary",children:e.jsx(f,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:s("help.note")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:s("help.helper")})]})]}),e.jsxs("div",{className:"rounded-[1rem] bg-secondary/55 p-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.62)]",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-primary/78",children:s("help.meta.recommendedFlow")}),e.jsx("ol",{className:"mt-2.5 space-y-2",children:a.map((i,n)=>e.jsxs("li",{className:"flex gap-2.5 text-xs leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary text-[10px] font-semibold text-primary-foreground",children:n+1}),e.jsx("span",{children:p(i)})]},`${n}-${i}`))})]})]})}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-1",children:c.map(i=>e.jsxs("a",{href:`#help-${i.id}`,className:P,children:[e.jsx("p",{className:"text-sm font-semibold",children:i.title}),e.jsx("p",{className:"mt-1.5 line-clamp-2 text-xs leading-5 text-muted-foreground",children:i.subtitle})]},i.id))})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{id:"help-configuration",children:e.jsx(o,{title:e.jsx(x,{eyebrow:"01",title:t[0].title}),description:s("help.clientConfig.subtitle"),children:e.jsx(m,{items:t[0].items,compact:!0})})}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold",children:s("help.clientConfig.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.clientConfig.subtitle")})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsxs(o,{title:e.jsx(x,{eyebrow:"02",title:t[1].title}),className:"rounded-[1.35rem]",children:[e.jsx(N,{icon:e.jsx(k,{className:"h-4 w-4"}),iconClassName:"bg-primary text-primary-foreground",title:"Claude Code",subtitle:s("help.meta.claudeWorkflow")}),e.jsx(m,{items:t[1].items})]})}),e.jsx("div",{id:"help-codex",children:e.jsxs(o,{title:e.jsx(x,{eyebrow:"03",title:t[2].title}),className:"rounded-[1.35rem]",children:[e.jsx(N,{icon:e.jsx(C,{className:"h-4 w-4"}),iconClassName:"bg-emerald-600 text-white",title:"Codex CLI",subtitle:s("help.meta.codexWorkflow")}),e.jsx(m,{items:t[2].items})]})})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"mb-6 space-y-1 text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("help.advancedGuide.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.advancedGuide.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(o,{title:e.jsx(x,{eyebrow:"04",title:t[3].title}),children:e.jsx(m,{items:t[3].items})}),e.jsx(o,{title:e.jsx(x,{eyebrow:"05",title:t[4].title}),children:e.jsx(m,{items:t[4].items})})]})]}),e.jsx("div",{id:"help-faq",children:e.jsx(o,{title:e.jsx(x,{eyebrow:"FAQ",title:s("help.faq.title")}),children:e.jsx(W,{items:l})})})]})]})]})}function x({eyebrow:s,title:t}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground/80",children:s}),e.jsx("h2",{className:"text-base font-semibold text-foreground",children:t})]})}function N({icon:s,iconClassName:t,title:l,subtitle:a}){return e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-[1rem] bg-secondary/78 p-3.5 shadow-[inset_0_1px_0_rgba(255,255,255,0.62)] dark:bg-slate-900/[0.56] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",children:[e.jsx("div",{className:h("flex h-10 w-10 items-center justify-center rounded-[0.95rem]",t),children:s}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]})]})}function m({items:s,compact:t=!1}){return e.jsx("ol",{className:h("flex flex-col",t?"gap-2":"gap-2.5"),children:s.map((l,a)=>e.jsxs("li",{className:h("flex gap-3 rounded-[1.05rem] border border-border/50 bg-card/92 shadow-[0_16px_36px_-30px_rgba(15,23,42,0.24)] dark:border-white/10 dark:bg-slate-950/[0.38] dark:shadow-[0_16px_36px_-30px_rgba(0,0,0,0.32)]",t?"p-3":"p-3.5"),children:[e.jsx("span",{className:h("flex shrink-0 items-center justify-center rounded-[0.95rem] bg-primary text-xs font-semibold text-primary-foreground shadow-[0_10px_22px_-14px_hsl(var(--primary)/0.7)]",t?"h-7 w-7 text-[11px]":"h-8 w-8"),children:a+1}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-muted-foreground",children:e.jsx(w,{content:l})})]},`${a}-${l}`))})}function w({content:s}){const{t}=y(),l=s.split("```");return e.jsx("div",{className:"space-y-3",children:l.map((a,c)=>{if(!a.trim())return null;if(c%2===1){const[i,...n]=a.split(`
1
+ import{r as g,j as e,aT as v,aQ as f,aU as k,ab as C}from"./vendor-z22RpOY0.js";import{P as $}from"./PageHeader-DCqHI67a.js";import{P as o}from"./PageSection-CuZMzA0E.js";import{c as q}from"./clipboard-CALi6bTW.js";import{c as h}from"./global-B-NXh5qD.js";import{C as j,a as b}from"./card-ChFVaqLf.js";import{B as S}from"./app-COiQeF3y.js";import{u as y}from"./i18n-Bl2BcCDG.js";import"./query-BbGWgOFk.js";import"./router-CL3rf_uf.js";import"./radix-mHySgtou.js";const O="group rounded-[1rem] border border-white/70 bg-card/95 p-3.5 shadow-[0_18px_42px_-38px_rgba(15,23,42,0.24)] transition hover:-translate-y-0.5 hover:shadow-[0_22px_48px_-40px_rgba(59,130,246,0.18)]";function R(){const{t:s}=y(),t=g.useMemo(()=>{const i=s("help.sections.configuration.items",{returnObjects:!0}),n=s("help.sections.claudeCodeConfig.items",{returnObjects:!0}),r=s("help.sections.codexConfig.items",{returnObjects:!0}),d=s("help.sections.usage.items",{returnObjects:!0}),_=s("help.sections.tips.items",{returnObjects:!0});return[{title:s("help.sections.configuration.title"),items:i},{title:s("help.sections.claudeCodeConfig.title"),items:n},{title:s("help.sections.codexConfig.title"),items:r},{title:s("help.sections.usage.title"),items:d},{title:s("help.sections.tips.title"),items:_}]},[s]),l=s("help.faq.items",{returnObjects:!0}),a=t[0].items.slice(0,3),c=g.useMemo(()=>[{id:"configuration",title:t[0].title,subtitle:p(t[0].items[0]??"")},{id:"claude",title:t[1].title,subtitle:p(t[1].items[0]??"")},{id:"codex",title:t[2].title,subtitle:p(t[2].items[0]??"")},{id:"faq",title:s("help.faq.title"),subtitle:s("help.meta.faqCount",{count:l.length})}],[l.length,t,s]);return e.jsxs("div",{className:"space-y-5",children:[e.jsx($,{icon:e.jsx(v,{className:"h-5 w-5","aria-hidden":"true"}),title:s("help.title"),description:s("help.intro"),breadcrumb:s("help.meta.breadcrumb"),helper:s("help.helper"),badge:s("help.meta.guides",{count:t.length})}),e.jsx(j,{className:"rounded-[1.2rem] border border-white/70 bg-card/95 shadow-[0_20px_50px_-42px_rgba(15,23,42,0.24)] xl:hidden",children:e.jsxs(b,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-[0.95rem] bg-accent text-primary",children:e.jsx(f,{className:"h-4.5 w-4.5","aria-hidden":"true"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:s("help.note")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:s("help.helper")})]})]}),e.jsxs("div",{className:"rounded-[0.95rem] bg-secondary/55 p-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.62)]",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-primary/78",children:s("help.meta.recommendedFlow")}),e.jsx("div",{className:"-mx-1 mt-2 flex gap-2 overflow-x-auto px-1 pb-1",children:c.map(i=>e.jsxs("a",{href:`#help-${i.id}`,className:"w-[190px] shrink-0 rounded-[0.95rem] border border-white/65 bg-background/82 px-3 py-2.5 shadow-[0_10px_24px_-20px_rgba(15,23,42,0.18)]",children:[e.jsx("p",{className:"text-[13px] font-semibold text-foreground",children:i.title}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-4.5 text-muted-foreground",children:i.subtitle})]},i.id))}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:a.map((i,n)=>e.jsxs("span",{className:"inline-flex items-center rounded-full bg-background/78 px-2.5 py-1 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"mr-1.5 inline-flex h-4.5 w-4.5 items-center justify-center rounded-full bg-primary text-[10px] font-semibold text-primary-foreground",children:n+1}),e.jsx("span",{className:"line-clamp-1",children:p(i)})]},`${n}-${i}`))})]})]})}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[280px_minmax(0,1fr)] xl:items-start",children:[e.jsxs("aside",{className:"hidden space-y-4 xl:sticky xl:top-24 xl:block",children:[e.jsx(j,{className:"rounded-[1.25rem] border border-white/70 bg-card/95 shadow-[0_20px_50px_-42px_rgba(15,23,42,0.24)]",children:e.jsxs(b,{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-[1rem] bg-accent text-primary",children:e.jsx(f,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:s("help.note")}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:s("help.helper")})]})]}),e.jsxs("div",{className:"rounded-[1rem] bg-secondary/55 p-3 shadow-[inset_0_1px_0_rgba(255,255,255,0.62)]",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] text-primary/78",children:s("help.meta.recommendedFlow")}),e.jsx("ol",{className:"mt-2.5 space-y-2",children:a.map((i,n)=>e.jsxs("li",{className:"flex gap-2.5 text-xs leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary text-[10px] font-semibold text-primary-foreground",children:n+1}),e.jsx("span",{children:p(i)})]},`${n}-${i}`))})]})]})}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-1",children:c.map(i=>e.jsxs("a",{href:`#help-${i.id}`,className:O,children:[e.jsx("p",{className:"text-sm font-semibold",children:i.title}),e.jsx("p",{className:"mt-1.5 line-clamp-2 text-xs leading-5 text-muted-foreground",children:i.subtitle})]},i.id))})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{id:"help-configuration",children:e.jsx(o,{title:e.jsx(x,{eyebrow:"01",title:t[0].title}),description:s("help.clientConfig.subtitle"),children:e.jsx(m,{items:t[0].items,compact:!0})})}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold",children:s("help.clientConfig.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.clientConfig.subtitle")})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx("div",{id:"help-claude",children:e.jsxs(o,{title:e.jsx(x,{eyebrow:"02",title:t[1].title}),className:"rounded-[1.35rem]",children:[e.jsx(N,{icon:e.jsx(k,{className:"h-4 w-4"}),iconClassName:"bg-primary text-primary-foreground",title:"Claude Code",subtitle:s("help.meta.claudeWorkflow")}),e.jsx(m,{items:t[1].items})]})}),e.jsx("div",{id:"help-codex",children:e.jsxs(o,{title:e.jsx(x,{eyebrow:"03",title:t[2].title}),className:"rounded-[1.35rem]",children:[e.jsx(N,{icon:e.jsx(C,{className:"h-4 w-4"}),iconClassName:"bg-emerald-600 text-white",title:"Codex CLI",subtitle:s("help.meta.codexWorkflow")}),e.jsx(m,{items:t[2].items})]})})]}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"mb-6 space-y-1 text-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("help.advancedGuide.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("help.advancedGuide.subtitle")})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsx(o,{title:e.jsx(x,{eyebrow:"04",title:t[3].title}),children:e.jsx(m,{items:t[3].items})}),e.jsx(o,{title:e.jsx(x,{eyebrow:"05",title:t[4].title}),children:e.jsx(m,{items:t[4].items})})]})]}),e.jsx("div",{id:"help-faq",children:e.jsx(o,{title:e.jsx(x,{eyebrow:"FAQ",title:s("help.faq.title")}),children:e.jsx(W,{items:l})})})]})]})]})}function x({eyebrow:s,title:t}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground/80",children:s}),e.jsx("h2",{className:"text-base font-semibold text-foreground",children:t})]})}function N({icon:s,iconClassName:t,title:l,subtitle:a}){return e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-[1rem] bg-secondary/78 p-3.5 shadow-[inset_0_1px_0_rgba(255,255,255,0.62)] dark:bg-slate-900/[0.56] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",children:[e.jsx("div",{className:h("flex h-10 w-10 items-center justify-center rounded-[0.95rem]",t),children:s}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]})]})}function m({items:s,compact:t=!1}){return e.jsx("ol",{className:h("flex flex-col",t?"gap-2":"gap-2.5"),children:s.map((l,a)=>e.jsxs("li",{className:h("flex gap-3 rounded-[1.05rem] border border-border/50 bg-card/92 shadow-[0_16px_36px_-30px_rgba(15,23,42,0.24)] dark:border-white/10 dark:bg-slate-950/[0.38] dark:shadow-[0_16px_36px_-30px_rgba(0,0,0,0.32)]",t?"p-3":"p-3.5"),children:[e.jsx("span",{className:h("flex shrink-0 items-center justify-center rounded-[0.95rem] bg-primary text-xs font-semibold text-primary-foreground shadow-[0_10px_22px_-14px_hsl(var(--primary)/0.7)]",t?"h-7 w-7 text-[11px]":"h-8 w-8"),children:a+1}),e.jsx("div",{className:"min-w-0 flex-1 text-sm text-muted-foreground",children:e.jsx(w,{content:l})})]},`${a}-${l}`))})}function w({content:s}){const{t}=y(),l=s.split("```");return e.jsx("div",{className:"space-y-3",children:l.map((a,c)=>{if(!a.trim())return null;if(c%2===1){const[i,...n]=a.split(`
2
2
  `),r=n.join(`
3
- `).trim();return e.jsxs("div",{className:"overflow-hidden rounded-[0.95rem] 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-2 dark:border-white/10",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:i||"bash"}),e.jsx(S,{variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:()=>q(r),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto px-3 py-3 font-mono text-[12px] leading-6 text-foreground",children:e.jsx("code",{className:"block min-w-full whitespace-pre",children:r})})]},c)}return e.jsx(O,{content:a},c)})})}function O({content:s}){const t=s.split(`
3
+ `).trim();return e.jsxs("div",{className:"overflow-hidden rounded-[0.95rem] 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-2 dark:border-white/10",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:i||"bash"}),e.jsx(S,{variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:()=>q(r),children:t("common.actions.copy")})]}),e.jsx("pre",{className:"overflow-x-auto px-3 py-3 font-mono text-[12px] leading-6 text-foreground",children:e.jsx("code",{className:"block min-w-full whitespace-pre",children:r})})]},c)}return e.jsx(P,{content:a},c)})})}function P({content:s}){const t=s.split(`
4
4
  `).map(r=>r.trimEnd()).filter(r=>r.trim().length>0);if(t.length===0)return null;const l=t.filter(r=>/^[-•*]\s+/.test(r.trim())),a=t.filter(r=>/^\d+[).]\s+/.test(r.trim())),c=t.filter(r=>!/^([-•*]|\d+[).])\s+/.test(r.trim())),i=l.map(r=>r.replace(/^[-•*]\s+/,"")),n=a.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.5",children:[c.length>0?e.jsx("div",{className:"space-y-2",children:c.map((r,d)=>e.jsx("p",{className:"leading-6",children:u(r)},`${r}-${d}`))}):null,i.length>0?e.jsx("ul",{className:"space-y-1.5 rounded-[0.95rem] bg-secondary/38 px-3 py-2.5 dark:bg-slate-900/[0.34]",children:i.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:u(r)})]},`${r}-${d}`))}):null,n.length>0?e.jsx("ol",{className:"space-y-2 rounded-[0.95rem] bg-secondary/38 px-3 py-2.5 dark:bg-slate-900/[0.34]",children:n.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/12 px-1.5 text-[11px] font-semibold text-primary",children:r.index}),e.jsx("span",{children:u(r.text)})]},`${r.index}-${r.text}`))}):null]})}function u(s){return s.split(/(`[^`]+`|\*\*[^*]+\*\*)/g).map((l,a)=>l.startsWith("`")&&l.endsWith("`")?e.jsx("code",{className:"rounded-md bg-secondary/72 px-1.5 py-0.5 text-[0.95em] text-foreground dark:bg-slate-900/[0.58]",children:l.slice(1,-1)},a):l.startsWith("**")&&l.endsWith("**")?e.jsx("strong",{className:"font-medium text-foreground",children:l.slice(2,-2)},a):e.jsx("span",{children:l},a))}function W({items:s}){return s.length===0?null:e.jsx("dl",{className:"space-y-2",children:s.map((t,l)=>e.jsxs("details",{className:"group overflow-hidden rounded-[1rem] border border-border/50 bg-card/92 shadow-[0_16px_36px_-30px_rgba(15,23,42,0.24)]",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-foreground",children:[e.jsx("span",{children:t.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:l+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(B,{content:t.a})})})]},t.q))})}function B({content:s}){return e.jsx(w,{content:s})}function p(s){var t;return((t=s.replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/^[-•*]\s+/gm,"").replace(/^\d+[).]\s+/gm,"").split(`
5
5
  `).map(l=>l.trim()).filter(Boolean)[0])==null?void 0:t.replace(/\s+/g," "))??""}export{R as default};
@@ -1 +1 @@
1
- import{r as n,j as e,ax as S,aR as E}from"./vendor-LWJeAdU1.js";import{h as k,L as F,B as L}from"./app-BG16DmZH.js";import{C as j,a as N,b as P,c as T,d as A,e as B}from"./card-CwTuH2Iq.js";import{I as b}from"./input-scp9nKJc.js";import{L as y}from"./label-fMXEnAEx.js";import{u as D}from"./i18n-B3N4Df3E.js";import{c as G,u as I}from"./router-DspBTS8b.js";import"./global-CKvMKvrn.js";import"./query-Cpxr1dul.js";import"./radix-bG5h1Ymq.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(P,{className:"pb-4 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground",children:"GW"}),e.jsx(T,{className:"text-xl",children:s("login.title")}),e.jsx(A,{children:s("login.description")})]}),e.jsx(N,{children:e.jsxs("form",{className:"space-y-4",onSubmit:C,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(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};
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 +1 @@
1
- import{r as m,j as e,au as Ze,af as Ye,a7 as et,av as tt,at as st,U as lt,P as Ee}from"./vendor-LWJeAdU1.js";import{P as at}from"./PageHeader--Lg_YQVw.js";import{c as j}from"./global-CKvMKvrn.js";import{B as _,b as rt,u as fe,s as D,t as ot,a as K}from"./app-BG16DmZH.js";import{B as A,q as V}from"./queryKeys-DTnZc8Yy.js";import{C as De,a as Fe}from"./card-CwTuH2Iq.js";import{I as xe}from"./input-scp9nKJc.js";import{L as U}from"./label-fMXEnAEx.js";import{S as te,a as se,b as le,c as ae,d as M}from"./select-BjYpeVvo.js";import{u as P}from"./i18n-B3N4Df3E.js";import{D as it,A as nt,a as dt,b as ct,c as pt,d as ut}from"./DialogShell-DcG-SXEV.js";import{P as mt,a as re}from"./PageState-DKba6Ew1.js";import{c as xt}from"./clipboard-CALi6bTW.js";import{u as B}from"./useApiQuery-jSeDDFuv.js";import{g as Te,f as gt,a as q,b as Re,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-BGSWKBlu.js";import{L as vt}from"./router-DspBTS8b.js";import{T as wt}from"./Skeleton-cyuMRxwQ.js";import{u as Nt}from"./query-Cpxr1dul.js";import{g as Ce}from"./gateway-CExOTXeI.js";import"./radix-bG5h1Ymq.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(De,{"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(Fe,{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(Ze,{className:"ml-1 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:[t("common.filters.expand"),e.jsx(Ye,{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(et,{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?Te(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(z,{label:s("logs.detail.info.latency"),value:q(a.latency_ms,s("common.units.ms"))}),e.jsx(z,{label:s("logs.detail.info.ttft"),value:q(a.ttft_ms,s("common.units.ms"))}),e.jsx(z,{label:s("logs.detail.info.tpot"),value:q(a.tpot_ms,s("common.units.msPerToken"))}),e.jsx(z,{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:Re(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(z,{label:s("logs.detail.info.inputTokens"),value:Q(a.input_tokens)}),e.jsx(z,{label:s("logs.detail.info.cacheReadTokens"),value:Q(a.cache_read_tokens)}),e.jsx(z,{label:s("logs.detail.info.cacheCreationTokens"),value:Q(a.cache_creation_tokens)}),e.jsx(z,{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 z({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(tt,{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(st,{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=Te(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:Re(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(De,{className:"overflow-hidden bg-card shadow-[var(--surface-shadow)]",children:e.jsxs(Fe,{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(lt,{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(Ee,{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 Ot(){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 zt(){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}=Ot(),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:Le,showScrollHint:Ke,tableScrollRef:Me,toggleColumn:Pe,visibleColumnCount:Ae,visibleColumns:Oe,visibleColumnSet:ze}=zt(),qe=m.useDeferredValue(h),T=h===""?"":qe;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]),O=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(()=>{!O.isError||!O.error||t({title:l("logs.toast.listError.title"),description:l("logs.toast.listError.desc",{message:O.error.message}),variant:"error"})},[O.error,O.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=O.data)==null?void 0:ve.total)??0,Z=ee>0?Math.ceil(ee/E):0,Qe=((we=O.data)==null?void 0:we.items)??[],Ie=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]),Ve=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??[],Ue=m.useMemo(()=>{const p=new Map;for(const v of ue)p.set(v.id,v);return p},[ue]),$e=m.useMemo(()=>oe.map(p=>({id:p,label:l(`logs.table.columns.${p}`)})),[l]),Y=m.useMemo(()=>new Date().toISOString().slice(0,10),[]),He=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([])},[]),Be=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:We,handleExport:Ge}=At({exportTimeoutMs:Ie,queryParams:ne,total:ee}),Je=m.useCallback(p=>{d.removeQueries({queryKey:["logs","detail"],type:"inactive"}),F(p),L(!0)},[d]),Xe=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:Ve,activeQuickView:He,apiKeyMap:Ue,apiKeys:ue,apiKeysQuery:ye,applyQuickView:Be,columnOptions:$e,customEndpoints:(Se=de.data)==null?void 0:Se.endpoints,endpointFilter:s,exporting:We,filtersExpanded:ie,fromDate:g,handleCloseDetail:Xe,handleExport:Ge,handleOpenDetail:Je,handleResetFilters:me,isDetailOpen:w,items:Qe,logsQuery:O,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:Le,setSelectedApiKeys:G,setStatusFilter:y,setToDate:i,showScrollHint:Ke,statusFilter:f,tableScrollRef:Me,toDate:a,toggleColumn:Pe,total:ee,totalPages:Z,visibleColumnCount:Ae,visibleColumns:Oe,visibleColumnSet:ze}}function ns(){var d;const{t:l}=P(),t=qt();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(at,{icon:e.jsx(Ee,{className:"h-5 w-5","aria-hidden":"true"}),title:l("logs.title"),description:l("logs.description"),eyebrow:"Traffic Explorer",breadcrumb:"Gateway / Logs",helper:l("logs.filtersDescription"),badge:t.total>0?l("logs.summary.total",{value:t.total.toLocaleString()}):void 0,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};
1
+ import{r as m,j as e,ay as Ze,al as Ye,a7 as et,az as tt,ax as st,U as lt,P as Ee}from"./vendor-z22RpOY0.js";import{P as at}from"./PageHeader-DCqHI67a.js";import{c as j}from"./global-B-NXh5qD.js";import{B as _,b as rt,u as fe,s as D,t as ot,a as K}from"./app-COiQeF3y.js";import{B as A,q as V}from"./queryKeys-ucXCzh0P.js";import{C as De,a as Fe}from"./card-ChFVaqLf.js";import{I as xe}from"./input-DW7jGTgj.js";import{L as U}from"./label-Ci1io7XA.js";import{S as te,a as se,b as le,c as ae,d as M}from"./select-BchX45jJ.js";import{u as P}from"./i18n-Bl2BcCDG.js";import{D as it,A as nt,a as dt,b as ct,c as pt,d as ut}from"./DialogShell-DcOGCV8m.js";import{P as mt,a as re}from"./PageState-B03H5AV0.js";import{c as xt}from"./clipboard-CALi6bTW.js";import{u as B}from"./useApiQuery-tbd4JJaZ.js";import{g as Te,f as gt,a as q,b as Re,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-CQHCVE2z.js";import{L as vt}from"./router-CL3rf_uf.js";import{T as wt}from"./Skeleton-i1PjWApN.js";import{u as Nt}from"./query-BbGWgOFk.js";import{g as Ce}from"./gateway-BU3dR2tm.js";import"./radix-mHySgtou.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(De,{"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(Fe,{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(Ze,{className:"ml-1 h-4 w-4"})]}):e.jsxs(e.Fragment,{children:[t("common.filters.expand"),e.jsx(Ye,{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(et,{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?Te(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:Re(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(tt,{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(st,{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=Te(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:Re(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(De,{className:"overflow-hidden bg-card shadow-[var(--surface-shadow)]",children:e.jsxs(Fe,{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(lt,{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(Ee,{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:Le,showScrollHint:Ke,tableScrollRef:Me,toggleColumn:Pe,visibleColumnCount:Ae,visibleColumns:ze,visibleColumnSet:Oe}=Ot(),qe=m.useDeferredValue(h),T=h===""?"":qe;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)??[],Ie=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]),Ve=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??[],Ue=m.useMemo(()=>{const p=new Map;for(const v of ue)p.set(v.id,v);return p},[ue]),$e=m.useMemo(()=>oe.map(p=>({id:p,label:l(`logs.table.columns.${p}`)})),[l]),Y=m.useMemo(()=>new Date().toISOString().slice(0,10),[]),He=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([])},[]),Be=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:We,handleExport:Ge}=At({exportTimeoutMs:Ie,queryParams:ne,total:ee}),Je=m.useCallback(p=>{d.removeQueries({queryKey:["logs","detail"],type:"inactive"}),F(p),L(!0)},[d]),Xe=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:Ve,activeQuickView:He,apiKeyMap:Ue,apiKeys:ue,apiKeysQuery:ye,applyQuickView:Be,columnOptions:$e,customEndpoints:(Se=de.data)==null?void 0:Se.endpoints,endpointFilter:s,exporting:We,filtersExpanded:ie,fromDate:g,handleCloseDetail:Xe,handleExport:Ge,handleOpenDetail:Je,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:Le,setSelectedApiKeys:G,setStatusFilter:y,setToDate:i,showScrollHint:Ke,statusFilter:f,tableScrollRef:Me,toDate:a,toggleColumn:Pe,total:ee,totalPages:Z,visibleColumnCount:Ae,visibleColumns:ze,visibleColumnSet:Oe}}function ns(){var d;const{t:l}=P(),t=qt();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(at,{icon:e.jsx(Ee,{className:"h-5 w-5","aria-hidden":"true"}),title:l("logs.title"),description:l("logs.description"),eyebrow:"Traffic Explorer",breadcrumb:"Gateway / Logs",helper:l("logs.filtersDescription"),badge:t.total>0?l("logs.summary.total",{value:t.total.toLocaleString()}):void 0,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};
@@ -1 +1 @@
1
- import{j as e,ax as ce,aB as me,aC as ue,N as xe,r as f,aa as pe,S as he}from"./vendor-LWJeAdU1.js";import{L as fe}from"./router-DspBTS8b.js";import{C as be}from"./ConfirmDialog-BHrsB4gR.js";import{P as ge}from"./PageHeader--Lg_YQVw.js";import{B as b}from"./app-BG16DmZH.js";import{B as W}from"./queryKeys-DTnZc8Yy.js";import{C as J,a as Z}from"./card-CwTuH2Iq.js";import{I as M}from"./input-scp9nKJc.js";import{u as E}from"./i18n-B3N4Df3E.js";import{D as ve,A as je,a as ye,b as we,c as Ne,d as ke,e as Me}from"./DialogShell-DcG-SXEV.js";import{L as C}from"./label-fMXEnAEx.js";import{S as Ce}from"./switch-CgwYcn5P.js";import{u as De}from"./useModelManagementState-9RhvWh8Y.js";import{c as Te}from"./global-CKvMKvrn.js";import"./query-Cpxr1dul.js";import"./radix-bG5h1Ymq.js";import"./gateway-CExOTXeI.js";import"./useAppMutation-ChCrgiP6.js";import"./useApiQuery-jSeDDFuv.js";function Pe({providersLength:d,filteredProviders:a,defaultLabels:c,providerSearch:g,providerTypeFilter:p,configPending:y,testingProviderId:s,onOpenEdit:t,onTestConnection:i,onRequestDelete:m,onProviderSearchChange:v,onResetFilters:w}){const{t:h}=E(),A=u=>{const D=u.authMode??(u.type==="anthropic"?"authToken":"apiKey");return D==="authToken"?"Bearer":D==="xAuthToken"?"X-Auth-Token":u.type==="anthropic"?"X-API-Key":h("providers.card.providerDefault")};return e.jsx(J,{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(Z,{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:g,onChange:u=>v(u.target.value),placeholder:h("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(W,{variant:"secondary",className:"rounded-full px-3 py-1 text-xs",children:h("providers.count",{count:a.length})}),e.jsx(b,{variant:"ghost",size:"sm",onClick:w,disabled:!g.trim()&&p==="all",className:"h-8 rounded-full px-3 text-xs",children:h("common.actions.reset")})]})]}),y?e.jsx("div",{className:"flex min-h-[200px] items-center justify-center rounded-lg bg-secondary text-sm text-muted-foreground",children:h("common.loading")}):d===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:h("providers.emptyState")}),e.jsx("p",{className:"mt-2 text-xs",children:h("providers.emptyStateSub",{default:"点击上方按钮添加您的第一个提供商"})})]}):a.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:h("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:a.map(u=>{var j;const D=A(u),T=((j=u.models)==null?void 0:j.length)??0,P=c.get(u.id);return e.jsx(Ue,{provider:u,authMode:D,modelCount:T,defaultModel:P,isTesting:s===u.id,onEdit:()=>t(u),onTest:()=>i(u),onDelete:()=>m(u),t:h},u.id)})})})]})})}function Ue({provider:d,authMode:a,modelCount:c,defaultModel:g,isTesting:p,onEdit:y,onTest:s,onDelete:t,t:i}){const m=!!g,v=m?"success":"warning",w=i(m?"providers.status.ready":"providers.status.needsDefault");return e.jsx(J,{"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(Z,{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:d.label||d.id,children:d.label||d.id})}),e.jsx("code",{className:"mt-0.5 block truncate text-[11px] text-muted-foreground",title:d.id,children:d.id})]}),e.jsx(W,{variant:v,className:"shrink-0 rounded-full px-2 py-0.5 text-[10px]",children:w})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5 text-[11px]",children:[e.jsx(Q,{icon:e.jsx(ce,{className:"h-3.5 w-3.5"}),label:i("providers.card.authMode"),value:a}),e.jsx(Q,{icon:e.jsx(me,{className:"h-3.5 w-3.5"}),label:i("providers.card.modelsTitle"),value:c>0?i("providers.card.modelCount",{count:c}):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(ue,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("code",{className:"truncate",title:d.baseUrl,children:d.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")}),g?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:g,children:g}):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(b,{variant:"ghost",size:"sm",onClick:y,className:"h-7 rounded-full px-2 text-[11px]",children:i("providers.actions.edit")}),e.jsx(b,{variant:"ghost",size:"sm",onClick:s,disabled:p,className:"h-7 rounded-full px-2 text-[11px]",children:p?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"mr-1 h-3 w-3 animate-spin"}),i("common.actions.testingConnection")]}):i("providers.actions.test")}),e.jsx(b,{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:d,label:a,value:c}){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:[d,e.jsx("span",{className:"truncate",children:a})]}),e.jsx("p",{className:"truncate text-[11px] font-medium text-foreground",title:c,children:c})]})}function Ae({open:d,provider:a,options:c,usePreset:g,preservedExtras:p,onPresetChange:y,onConfirm:s,onClose:t}){const{t:i}=E();return a?e.jsx(ve,{open:d,onOpenChange:m=>!m&&t(),children:e.jsxs(je,{className:"max-w-2xl",children:[e.jsxs(ye,{children:[e.jsx(we,{children:i("providers.testDialog.title")}),e.jsx(Ne,{children:i("providers.testDialog.subtitle",{name:a.label||a.id})})]}),e.jsxs(ke,{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(C,{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(Ce,{id:"provider-test-preset",checked:g,onCheckedChange:y})})]}),g?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:c.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(p).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(p).map(([m,v])=>e.jsxs("code",{className:"block rounded-lg border border-transparent bg-card px-2 py-1 shadow-[var(--surface-shadow)]",children:[m,": ",v]},m))]})]}),e.jsxs(Me,{children:[e.jsx(b,{variant:"outline",onClick:t,children:i("providers.testDialog.cancel")}),e.jsx(b,{onClick:()=>void s(),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 _={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 I(d){return d==="anthropic"?"authToken":"apiKey"}function Y(d){return d?{id:d.id,label:d.label??d.id,baseUrl:d.baseUrl,apiKey:d.apiKey??"",type:d.type??"custom",defaultModel:d.defaultModel??"",models:(d.models??[]).map(a=>({...a,_key:F()})),authMode:d.authMode??I(d.type??"custom")}:{id:"",label:"",baseUrl:"",apiKey:"",type:"custom",defaultModel:"",models:[],authMode:I("custom")}}function _e(d){return{_key:F(),id:d.id,label:d.label}}function Ie({open:d,mode:a,provider:c,existingProviderIds:g,onClose:p,onSubmit:y}){const{t:s}=E(),[t,i]=f.useState(()=>Y(c)),[m,v]=f.useState({}),[w,h]=f.useState(!1),[A,u]=f.useState(null),D=f.useRef(null),T=f.useRef(null),P=f.useRef(null),[j,H]=f.useState(a==="edit");f.useEffect(()=>{d&&(i(Y(c)),v({}),u(null),h(!1),H(a==="edit"))},[d,c,a]),f.useEffect(()=>{if(!d)return;const r=l=>{l.key==="Escape"&&p()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[d,p]),f.useEffect(()=>{if(d){if(a==="create"&&P.current){P.current.focus();return}T.current&&T.current.focus()}},[d,a]);const L=a==="create",K=f.useMemo(()=>t.models.filter(r=>r.id.trim().length>0),[t.models]),z=f.useMemo(()=>{var r;return((r=V.find(l=>l.value===t.type))==null?void 0:r.label)??"Custom"},[t.type]),q=(r,l)=>s(l==="authToken"?"providers.drawer.fields.authModeAuthToken":l==="xAuthToken"?"providers.drawer.fields.authModeXAuthToken":r==="anthropic"?"providers.drawer.fields.authModeApiKey":"providers.drawer.fields.authModeProviderDefault"),$=t.label.trim()||t.id.trim()||s("providers.drawer.summary.untitled"),X=f.useMemo(()=>[{label:s("providers.drawer.summary.type"),value:z},{label:s("providers.drawer.summary.auth"),value:q(t.type,t.authMode)},{label:s("providers.drawer.summary.models"),value:K.length.toLocaleString()}],[K.length,t.authMode,t.type,z,s]),R=r=>l=>{i(n=>({...n,[r]:l}))},ee=r=>{i(l=>{const o=!j||l.label.trim().length===0||l.label===l.id?r:l.label;return{...l,id:r,label:o}})},re=r=>{i(l=>{var G;const o=_[r??"custom"]??_.custom,x=I(l.type),N=I(r),k=Object.values(_).map(U=>U.baseUrl).filter(U=>!!U),B=!l.baseUrl||k.includes(l.baseUrl),ne=a==="create"&&(l.models.length===0||l.models.every(U=>U.id.trim().length===0)),S={...l,type:r,authMode:l.authMode===x?N:l.authMode};return o!=null&&o.baseUrl&&B&&(S.baseUrl=o.baseUrl),o!=null&&o.models&&ne&&(S.models=o.models.map(_e),S.defaultModel=o.defaultModel??((G=o.models[0])==null?void 0:G.id)??""),S})},se=(r,l)=>{i(n=>{const o=[...n.models];return o[r]={...o[r],...l},{...n,models:o}})},ae=(r,l)=>{i(n=>{const o=[...n.models],x=o[r];if(!x)return n;const N=!j||!x.label||x.label===x.id,k={...x,id:l,label:N?l:x.label};o[r]=k;const B=n.defaultModel===x.id?l:n.defaultModel;return{...n,models:o,defaultModel:B}})},te=r=>{i(l=>{if(r<0||r>=l.models.length)return l;const n=l.models.filter((x,N)=>N!==r);let o=l.defaultModel;return n.some(x=>x.id===o)||(o=""),{...l,models:n,defaultModel:o}})},de=()=>{i(r=>({...r,models:[...r.models,Se()]}))},O=r=>{i(l=>({...l,authMode:r}))},le=()=>{const r={},l=t.id.trim(),n=t.baseUrl.trim();if(a==="create"&&(l.length===0?r.id=s("providers.drawer.errors.idRequired"):g.includes(l)&&(r.id=s("providers.drawer.errors.idDuplicate"))),a==="edit"&&l.length===0&&(r.id=s("providers.drawer.errors.idRequired")),n.length===0)r.baseUrl=s("providers.drawer.errors.baseUrlInvalid");else try{new URL(n)}catch{r.baseUrl=s("providers.drawer.errors.baseUrlInvalid")}if(t.models.length>0){const o=new Set;t.models.some(N=>{const k=N.id.trim();return k.length===0||o.has(k)?!0:(o.add(k),!1)})&&(r.models=s("providers.drawer.errors.modelInvalid"))}return t.defaultModel&&!t.models.some(o=>o.id===t.defaultModel)&&(r.models=s("providers.drawer.errors.defaultInvalid")),v(r),Object.keys(r).length===0},ie=()=>{const r=t.models.map(o=>{var x;return{id:o.id.trim(),label:(x=o.label)!=null&&x.trim()?o.label.trim():void 0}}).filter(o=>o.id.length>0),l=c!=null&&c.extraHeaders&&Object.keys(c.extraHeaders).length>0?c.extraHeaders:void 0,n=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:l,authMode:n}},oe=async()=>{if(u(null),!!le()){h(!0);try{const r=ie();await y(r)}catch(r){u(s("providers.drawer.toast.saveFailure",{message:r instanceof Error?r.message:"unknown"})),h(!1);return}h(!1),p()}};return d?e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-background/80 backdrop-blur-sm",onClick:p,"aria-hidden":"true"}),e.jsxs("aside",{ref:D,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:s(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:s(L?"providers.drawer.createTitle":"providers.drawer.editTitle")}),e.jsx("p",{id:"provider-drawer-desc",className:"text-sm text-muted-foreground",children:s("providers.drawer.description")})]})]}),e.jsx(b,{type:"button",ref:T,variant:"outline",onClick:p,className:"bg-card",children:s("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:s("providers.drawer.sections.type")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.hints.type")})]}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:V.map(r=>{var n;const l=r.value===t.type;return e.jsxs("button",{type:"button",onClick:()=>re(r.value),className:Te("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",l?"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:((n=_[r.value??"custom"])==null?void 0:n.baseUrl)??s("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:s("providers.drawer.sections.basic")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.hints.basic")})]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:()=>H(r=>!r),className:"bg-card text-xs",children:s(j?"providers.drawer.fields.hideAdvanced":"providers.drawer.fields.showAdvanced")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.id")}),e.jsx(M,{value:t.id,ref:P,onChange:r=>ee(r.target.value),disabled:!L,placeholder:s("providers.drawer.fields.idPlaceholder"),"aria-invalid":!!m.id}),m.id?e.jsx("span",{className:"text-xs text-destructive",children:m.id}):null]}),e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.label")}),e.jsx(M,{value:t.label,onChange:r=>R("label")(r.target.value),placeholder:s("providers.drawer.fields.labelPlaceholder")})]})]}),e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.baseUrl")}),e.jsx(M,{value:t.baseUrl,onChange:r=>R("baseUrl")(r.target.value),placeholder:s("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:s("providers.drawer.sections.auth")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.hints.auth")})]}),e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.apiKey")}),e.jsx(M,{value:t.apiKey,onChange:r=>R("apiKey")(r.target.value),placeholder:s("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:s("providers.drawer.fields.authMode")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s("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:()=>O("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:()=>O("authToken"),className:"mt-0.5 h-4 w-4 accent-[hsl(var(--primary))]"}),e.jsx("span",{children:s("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:()=>O("xAuthToken"),className:"mt-0.5 h-4 w-4 accent-[hsl(var(--primary))]"}),e.jsx("span",{children:s("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:s("providers.drawer.fields.models")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.modelsDescription")})]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:de,className:"bg-card text-xs",children:s("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,l)=>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(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.modelId")}),e.jsx(M,{value:r.id,onChange:n=>ae(l,n.target.value),placeholder:s("providers.drawer.fields.modelIdPlaceholder")})]}),j?e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.modelLabel")}),e.jsx(M,{value:r.label??"",onChange:n=>se(l,{label:n.target.value}),placeholder:s("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(n=>({...n,defaultModel:r.id})),disabled:r.id.trim().length===0,className:"h-4 w-4 accent-[hsl(var(--primary))]"}),s("providers.drawer.fields.setDefault")]}),e.jsx(b,{type:"button",variant:"ghost",size:"sm",className:"h-auto px-2 text-destructive",onClick:()=>te(l),disabled:t.models.length===0,children:s("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:s("providers.drawer.noModelsTitle")}),e.jsx("p",{className:"text-xs leading-relaxed text-amber-800 dark:text-amber-300",children:s("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:s("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:s("providers.drawer.defaultHint",{model:t.defaultModel||s("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:s("providers.drawer.formSummary")}),e.jsx("p",{className:"mt-2 text-base font-semibold",children:$}),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:s("providers.drawer.sections.checklist")}),e.jsxs("ul",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("li",{children:s("providers.drawer.hints.checkUrl")}),e.jsx("li",{children:s("providers.drawer.hints.checkAuth")}),e.jsx("li",{children:s("providers.drawer.hints.checkModels")})]})]}),j&&e.jsxs("div",{className:"rounded-xl bg-accent p-4 text-sm text-foreground",children:[e.jsx("p",{className:"font-medium text-primary",children:s("providers.drawer.hints.advancedTitle")}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("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:A?e.jsx("span",{children:A}):null}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{type:"button",variant:"outline",onClick:p,disabled:w,className:"bg-card",children:s("common.actions.cancel")}),e.jsx(b,{type:"button",onClick:oe,disabled:w,children:s(w?"common.actions.saving":"common.actions.save")})]})]})]})]}):null}function er(){const{t:d}=E(),a=De();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ge,{icon:e.jsx(he,{className:"h-5 w-5","aria-hidden":"true"}),title:d("providers.title"),description:d("providers.description"),eyebrow:d("modelManagement.providersEyebrow"),breadcrumb:"Gateway / Providers",badge:d("providers.count",{count:a.providerCount}),actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx(b,{asChild:!0,variant:"outline",className:"w-full sm:w-auto",children:e.jsxs(fe,{to:"/routing",children:[d("nav.routing"),e.jsx(pe,{className:"h-4 w-4","aria-hidden":"true"})]})}),e.jsx(b,{onClick:a.handleOpenCreate,className:"w-full sm:w-auto",children:d("providers.actions.add")})]})}),e.jsx(Pe,{configPending:a.configQuery.isPending||!a.config&&a.configQuery.isFetching,defaultLabels:a.defaultLabels,filteredProviders:a.filteredProviders,onOpenEdit:a.handleOpenEdit,onRequestDelete:c=>a.setConfirmAction({kind:"provider",provider:c}),onResetFilters:()=>{a.setProviderSearch(""),a.setProviderTypeFilter("all")},onProviderSearchChange:a.setProviderSearch,onProviderTypeChange:a.setProviderTypeFilter,onTestConnection:a.initiateTestConnection,providerSearch:a.providerSearch,providerTypeFilter:a.providerTypeFilter,providersLength:a.providers.length,testingProviderId:a.testingProviderId}),e.jsx(Ie,{open:a.drawerOpen,mode:a.drawerMode,provider:a.drawerMode==="edit"?a.editingProvider:void 0,existingProviderIds:a.providers.map(c=>c.id).filter(c=>a.drawerMode==="edit"&&a.editingProvider?c!==a.editingProvider.id:!0),onClose:()=>{a.setDrawerOpen(!1),a.setEditingProvider(void 0),a.setDrawerMode("create")},onSubmit:a.handleProviderSubmit}),e.jsx(Ae,{open:a.testDialogOpen,provider:a.testDialogProvider,options:a.anthropicTestHeaderOptions,preservedExtras:a.testDialogPreservedExtras,usePreset:a.testDialogUsePreset,onPresetChange:a.setTestDialogUsePreset,onConfirm:a.confirmTestDialog,onClose:a.closeTestDialog}),e.jsx(be,{open:!!a.confirmAction,onOpenChange:c=>{!c&&!a.confirmingAction&&a.setConfirmAction(null)},title:a.confirmDialogTitle,description:a.confirmDialogDescription,confirmLabel:a.confirmingAction?d("common.actions.loading"):d("common.delete"),cancelLabel:d("common.actions.cancel"),loading:a.confirmingAction,onConfirm:a.handleConfirmDialog,children:a.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:a.confirmDialogName}):null})]})}export{er as default};
1
+ import{j as e,aB as ce,aF as me,aG as ue,N as xe,r as f,ac as pe,S as he}from"./vendor-z22RpOY0.js";import{L as fe}from"./router-CL3rf_uf.js";import{C as be}from"./ConfirmDialog-oYHVEpGJ.js";import{P as ge}from"./PageHeader-DCqHI67a.js";import{B as b}from"./app-COiQeF3y.js";import{B as W}from"./queryKeys-ucXCzh0P.js";import{C as J,a as Z}from"./card-ChFVaqLf.js";import{I as M}from"./input-DW7jGTgj.js";import{u as E}from"./i18n-Bl2BcCDG.js";import{D as ve,A as je,a as ye,b as we,c as Ne,d as ke,e as Me}from"./DialogShell-DcOGCV8m.js";import{L as C}from"./label-Ci1io7XA.js";import{S as Ce}from"./switch-CT24uL_Q.js";import{u as De}from"./useModelManagementState-DcQ0Ac-x.js";import{c as Te}from"./global-B-NXh5qD.js";import"./query-BbGWgOFk.js";import"./radix-mHySgtou.js";import"./gateway-BU3dR2tm.js";import"./useAppMutation-SONU2xFC.js";import"./useApiQuery-tbd4JJaZ.js";function Pe({providersLength:d,filteredProviders:a,defaultLabels:c,providerSearch:g,providerTypeFilter:p,configPending:y,testingProviderId:s,onOpenEdit:t,onTestConnection:i,onRequestDelete:m,onProviderSearchChange:v,onResetFilters:w}){const{t:h}=E(),A=u=>{const D=u.authMode??(u.type==="anthropic"?"authToken":"apiKey");return D==="authToken"?"Bearer":D==="xAuthToken"?"X-Auth-Token":u.type==="anthropic"?"X-API-Key":h("providers.card.providerDefault")};return e.jsx(J,{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(Z,{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:g,onChange:u=>v(u.target.value),placeholder:h("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(W,{variant:"secondary",className:"rounded-full px-3 py-1 text-xs",children:h("providers.count",{count:a.length})}),e.jsx(b,{variant:"ghost",size:"sm",onClick:w,disabled:!g.trim()&&p==="all",className:"h-8 rounded-full px-3 text-xs",children:h("common.actions.reset")})]})]}),y?e.jsx("div",{className:"flex min-h-[200px] items-center justify-center rounded-lg bg-secondary text-sm text-muted-foreground",children:h("common.loading")}):d===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:h("providers.emptyState")}),e.jsx("p",{className:"mt-2 text-xs",children:h("providers.emptyStateSub",{default:"点击上方按钮添加您的第一个提供商"})})]}):a.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:h("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:a.map(u=>{var j;const D=A(u),T=((j=u.models)==null?void 0:j.length)??0,P=c.get(u.id);return e.jsx(Ue,{provider:u,authMode:D,modelCount:T,defaultModel:P,isTesting:s===u.id,onEdit:()=>t(u),onTest:()=>i(u),onDelete:()=>m(u),t:h},u.id)})})})]})})}function Ue({provider:d,authMode:a,modelCount:c,defaultModel:g,isTesting:p,onEdit:y,onTest:s,onDelete:t,t:i}){const m=!!g,v=m?"success":"warning",w=i(m?"providers.status.ready":"providers.status.needsDefault");return e.jsx(J,{"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(Z,{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:d.label||d.id,children:d.label||d.id})}),e.jsx("code",{className:"mt-0.5 block truncate text-[11px] text-muted-foreground",title:d.id,children:d.id})]}),e.jsx(W,{variant:v,className:"shrink-0 rounded-full px-2 py-0.5 text-[10px]",children:w})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5 text-[11px]",children:[e.jsx(Q,{icon:e.jsx(ce,{className:"h-3.5 w-3.5"}),label:i("providers.card.authMode"),value:a}),e.jsx(Q,{icon:e.jsx(me,{className:"h-3.5 w-3.5"}),label:i("providers.card.modelsTitle"),value:c>0?i("providers.card.modelCount",{count:c}):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(ue,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("code",{className:"truncate",title:d.baseUrl,children:d.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")}),g?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:g,children:g}):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(b,{variant:"ghost",size:"sm",onClick:y,className:"h-7 rounded-full px-2 text-[11px]",children:i("providers.actions.edit")}),e.jsx(b,{variant:"ghost",size:"sm",onClick:s,disabled:p,className:"h-7 rounded-full px-2 text-[11px]",children:p?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"mr-1 h-3 w-3 animate-spin"}),i("common.actions.testingConnection")]}):i("providers.actions.test")}),e.jsx(b,{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:d,label:a,value:c}){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:[d,e.jsx("span",{className:"truncate",children:a})]}),e.jsx("p",{className:"truncate text-[11px] font-medium text-foreground",title:c,children:c})]})}function Ae({open:d,provider:a,options:c,usePreset:g,preservedExtras:p,onPresetChange:y,onConfirm:s,onClose:t}){const{t:i}=E();return a?e.jsx(ve,{open:d,onOpenChange:m=>!m&&t(),children:e.jsxs(je,{className:"max-w-2xl",children:[e.jsxs(ye,{children:[e.jsx(we,{children:i("providers.testDialog.title")}),e.jsx(Ne,{children:i("providers.testDialog.subtitle",{name:a.label||a.id})})]}),e.jsxs(ke,{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(C,{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(Ce,{id:"provider-test-preset",checked:g,onCheckedChange:y})})]}),g?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:c.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(p).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(p).map(([m,v])=>e.jsxs("code",{className:"block rounded-lg border border-transparent bg-card px-2 py-1 shadow-[var(--surface-shadow)]",children:[m,": ",v]},m))]})]}),e.jsxs(Me,{children:[e.jsx(b,{variant:"outline",onClick:t,children:i("providers.testDialog.cancel")}),e.jsx(b,{onClick:()=>void s(),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 _={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 I(d){return d==="anthropic"?"authToken":"apiKey"}function Y(d){return d?{id:d.id,label:d.label??d.id,baseUrl:d.baseUrl,apiKey:d.apiKey??"",type:d.type??"custom",defaultModel:d.defaultModel??"",models:(d.models??[]).map(a=>({...a,_key:F()})),authMode:d.authMode??I(d.type??"custom")}:{id:"",label:"",baseUrl:"",apiKey:"",type:"custom",defaultModel:"",models:[],authMode:I("custom")}}function _e(d){return{_key:F(),id:d.id,label:d.label}}function Ie({open:d,mode:a,provider:c,existingProviderIds:g,onClose:p,onSubmit:y}){const{t:s}=E(),[t,i]=f.useState(()=>Y(c)),[m,v]=f.useState({}),[w,h]=f.useState(!1),[A,u]=f.useState(null),D=f.useRef(null),T=f.useRef(null),P=f.useRef(null),[j,H]=f.useState(a==="edit");f.useEffect(()=>{d&&(i(Y(c)),v({}),u(null),h(!1),H(a==="edit"))},[d,c,a]),f.useEffect(()=>{if(!d)return;const r=l=>{l.key==="Escape"&&p()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[d,p]),f.useEffect(()=>{if(d){if(a==="create"&&P.current){P.current.focus();return}T.current&&T.current.focus()}},[d,a]);const L=a==="create",K=f.useMemo(()=>t.models.filter(r=>r.id.trim().length>0),[t.models]),z=f.useMemo(()=>{var r;return((r=V.find(l=>l.value===t.type))==null?void 0:r.label)??"Custom"},[t.type]),q=(r,l)=>s(l==="authToken"?"providers.drawer.fields.authModeAuthToken":l==="xAuthToken"?"providers.drawer.fields.authModeXAuthToken":r==="anthropic"?"providers.drawer.fields.authModeApiKey":"providers.drawer.fields.authModeProviderDefault"),$=t.label.trim()||t.id.trim()||s("providers.drawer.summary.untitled"),X=f.useMemo(()=>[{label:s("providers.drawer.summary.type"),value:z},{label:s("providers.drawer.summary.auth"),value:q(t.type,t.authMode)},{label:s("providers.drawer.summary.models"),value:K.length.toLocaleString()}],[K.length,t.authMode,t.type,z,s]),R=r=>l=>{i(n=>({...n,[r]:l}))},ee=r=>{i(l=>{const o=!j||l.label.trim().length===0||l.label===l.id?r:l.label;return{...l,id:r,label:o}})},re=r=>{i(l=>{var G;const o=_[r??"custom"]??_.custom,x=I(l.type),N=I(r),k=Object.values(_).map(U=>U.baseUrl).filter(U=>!!U),B=!l.baseUrl||k.includes(l.baseUrl),ne=a==="create"&&(l.models.length===0||l.models.every(U=>U.id.trim().length===0)),S={...l,type:r,authMode:l.authMode===x?N:l.authMode};return o!=null&&o.baseUrl&&B&&(S.baseUrl=o.baseUrl),o!=null&&o.models&&ne&&(S.models=o.models.map(_e),S.defaultModel=o.defaultModel??((G=o.models[0])==null?void 0:G.id)??""),S})},se=(r,l)=>{i(n=>{const o=[...n.models];return o[r]={...o[r],...l},{...n,models:o}})},ae=(r,l)=>{i(n=>{const o=[...n.models],x=o[r];if(!x)return n;const N=!j||!x.label||x.label===x.id,k={...x,id:l,label:N?l:x.label};o[r]=k;const B=n.defaultModel===x.id?l:n.defaultModel;return{...n,models:o,defaultModel:B}})},te=r=>{i(l=>{if(r<0||r>=l.models.length)return l;const n=l.models.filter((x,N)=>N!==r);let o=l.defaultModel;return n.some(x=>x.id===o)||(o=""),{...l,models:n,defaultModel:o}})},de=()=>{i(r=>({...r,models:[...r.models,Se()]}))},O=r=>{i(l=>({...l,authMode:r}))},le=()=>{const r={},l=t.id.trim(),n=t.baseUrl.trim();if(a==="create"&&(l.length===0?r.id=s("providers.drawer.errors.idRequired"):g.includes(l)&&(r.id=s("providers.drawer.errors.idDuplicate"))),a==="edit"&&l.length===0&&(r.id=s("providers.drawer.errors.idRequired")),n.length===0)r.baseUrl=s("providers.drawer.errors.baseUrlInvalid");else try{new URL(n)}catch{r.baseUrl=s("providers.drawer.errors.baseUrlInvalid")}if(t.models.length>0){const o=new Set;t.models.some(N=>{const k=N.id.trim();return k.length===0||o.has(k)?!0:(o.add(k),!1)})&&(r.models=s("providers.drawer.errors.modelInvalid"))}return t.defaultModel&&!t.models.some(o=>o.id===t.defaultModel)&&(r.models=s("providers.drawer.errors.defaultInvalid")),v(r),Object.keys(r).length===0},ie=()=>{const r=t.models.map(o=>{var x;return{id:o.id.trim(),label:(x=o.label)!=null&&x.trim()?o.label.trim():void 0}}).filter(o=>o.id.length>0),l=c!=null&&c.extraHeaders&&Object.keys(c.extraHeaders).length>0?c.extraHeaders:void 0,n=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:l,authMode:n}},oe=async()=>{if(u(null),!!le()){h(!0);try{const r=ie();await y(r)}catch(r){u(s("providers.drawer.toast.saveFailure",{message:r instanceof Error?r.message:"unknown"})),h(!1);return}h(!1),p()}};return d?e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 bg-background/80 backdrop-blur-sm",onClick:p,"aria-hidden":"true"}),e.jsxs("aside",{ref:D,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:s(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:s(L?"providers.drawer.createTitle":"providers.drawer.editTitle")}),e.jsx("p",{id:"provider-drawer-desc",className:"text-sm text-muted-foreground",children:s("providers.drawer.description")})]})]}),e.jsx(b,{type:"button",ref:T,variant:"outline",onClick:p,className:"bg-card",children:s("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:s("providers.drawer.sections.type")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.hints.type")})]}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:V.map(r=>{var n;const l=r.value===t.type;return e.jsxs("button",{type:"button",onClick:()=>re(r.value),className:Te("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",l?"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:((n=_[r.value??"custom"])==null?void 0:n.baseUrl)??s("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:s("providers.drawer.sections.basic")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.hints.basic")})]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:()=>H(r=>!r),className:"bg-card text-xs",children:s(j?"providers.drawer.fields.hideAdvanced":"providers.drawer.fields.showAdvanced")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.id")}),e.jsx(M,{value:t.id,ref:P,onChange:r=>ee(r.target.value),disabled:!L,placeholder:s("providers.drawer.fields.idPlaceholder"),"aria-invalid":!!m.id}),m.id?e.jsx("span",{className:"text-xs text-destructive",children:m.id}):null]}),e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.label")}),e.jsx(M,{value:t.label,onChange:r=>R("label")(r.target.value),placeholder:s("providers.drawer.fields.labelPlaceholder")})]})]}),e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.baseUrl")}),e.jsx(M,{value:t.baseUrl,onChange:r=>R("baseUrl")(r.target.value),placeholder:s("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:s("providers.drawer.sections.auth")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.hints.auth")})]}),e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.apiKey")}),e.jsx(M,{value:t.apiKey,onChange:r=>R("apiKey")(r.target.value),placeholder:s("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:s("providers.drawer.fields.authMode")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s("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:()=>O("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:()=>O("authToken"),className:"mt-0.5 h-4 w-4 accent-[hsl(var(--primary))]"}),e.jsx("span",{children:s("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:()=>O("xAuthToken"),className:"mt-0.5 h-4 w-4 accent-[hsl(var(--primary))]"}),e.jsx("span",{children:s("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:s("providers.drawer.fields.models")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("providers.drawer.modelsDescription")})]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:de,className:"bg-card text-xs",children:s("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,l)=>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(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.modelId")}),e.jsx(M,{value:r.id,onChange:n=>ae(l,n.target.value),placeholder:s("providers.drawer.fields.modelIdPlaceholder")})]}),j?e.jsxs(C,{className:"flex flex-col gap-2 text-sm",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s("providers.drawer.fields.modelLabel")}),e.jsx(M,{value:r.label??"",onChange:n=>se(l,{label:n.target.value}),placeholder:s("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(n=>({...n,defaultModel:r.id})),disabled:r.id.trim().length===0,className:"h-4 w-4 accent-[hsl(var(--primary))]"}),s("providers.drawer.fields.setDefault")]}),e.jsx(b,{type:"button",variant:"ghost",size:"sm",className:"h-auto px-2 text-destructive",onClick:()=>te(l),disabled:t.models.length===0,children:s("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:s("providers.drawer.noModelsTitle")}),e.jsx("p",{className:"text-xs leading-relaxed text-amber-800 dark:text-amber-300",children:s("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:s("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:s("providers.drawer.defaultHint",{model:t.defaultModel||s("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:s("providers.drawer.formSummary")}),e.jsx("p",{className:"mt-2 text-base font-semibold",children:$}),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:s("providers.drawer.sections.checklist")}),e.jsxs("ul",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("li",{children:s("providers.drawer.hints.checkUrl")}),e.jsx("li",{children:s("providers.drawer.hints.checkAuth")}),e.jsx("li",{children:s("providers.drawer.hints.checkModels")})]})]}),j&&e.jsxs("div",{className:"rounded-xl bg-accent p-4 text-sm text-foreground",children:[e.jsx("p",{className:"font-medium text-primary",children:s("providers.drawer.hints.advancedTitle")}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("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:A?e.jsx("span",{children:A}):null}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{type:"button",variant:"outline",onClick:p,disabled:w,className:"bg-card",children:s("common.actions.cancel")}),e.jsx(b,{type:"button",onClick:oe,disabled:w,children:s(w?"common.actions.saving":"common.actions.save")})]})]})]})]}):null}function er(){const{t:d}=E(),a=De();return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ge,{icon:e.jsx(he,{className:"h-5 w-5","aria-hidden":"true"}),title:d("providers.title"),description:d("providers.description"),eyebrow:d("modelManagement.providersEyebrow"),breadcrumb:"Gateway / Providers",badge:d("providers.count",{count:a.providerCount}),actions:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsx(b,{asChild:!0,variant:"outline",className:"w-full sm:w-auto",children:e.jsxs(fe,{to:"/routing",children:[d("nav.routing"),e.jsx(pe,{className:"h-4 w-4","aria-hidden":"true"})]})}),e.jsx(b,{onClick:a.handleOpenCreate,className:"w-full sm:w-auto",children:d("providers.actions.add")})]})}),e.jsx(Pe,{configPending:a.configQuery.isPending||!a.config&&a.configQuery.isFetching,defaultLabels:a.defaultLabels,filteredProviders:a.filteredProviders,onOpenEdit:a.handleOpenEdit,onRequestDelete:c=>a.setConfirmAction({kind:"provider",provider:c}),onResetFilters:()=>{a.setProviderSearch(""),a.setProviderTypeFilter("all")},onProviderSearchChange:a.setProviderSearch,onProviderTypeChange:a.setProviderTypeFilter,onTestConnection:a.initiateTestConnection,providerSearch:a.providerSearch,providerTypeFilter:a.providerTypeFilter,providersLength:a.providers.length,testingProviderId:a.testingProviderId}),e.jsx(Ie,{open:a.drawerOpen,mode:a.drawerMode,provider:a.drawerMode==="edit"?a.editingProvider:void 0,existingProviderIds:a.providers.map(c=>c.id).filter(c=>a.drawerMode==="edit"&&a.editingProvider?c!==a.editingProvider.id:!0),onClose:()=>{a.setDrawerOpen(!1),a.setEditingProvider(void 0),a.setDrawerMode("create")},onSubmit:a.handleProviderSubmit}),e.jsx(Ae,{open:a.testDialogOpen,provider:a.testDialogProvider,options:a.anthropicTestHeaderOptions,preservedExtras:a.testDialogPreservedExtras,usePreset:a.testDialogUsePreset,onPresetChange:a.setTestDialogUsePreset,onConfirm:a.confirmTestDialog,onClose:a.closeTestDialog}),e.jsx(be,{open:!!a.confirmAction,onOpenChange:c=>{!c&&!a.confirmingAction&&a.setConfirmAction(null)},title:a.confirmDialogTitle,description:a.confirmDialogDescription,confirmLabel:a.confirmingAction?d("common.actions.loading"):d("common.delete"),cancelLabel:d("common.actions.cancel"),loading:a.confirmingAction,onConfirm:a.handleConfirmDialog,children:a.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:a.confirmDialogName}):null})]})}export{er as default};
@@ -1 +1 @@
1
- import{j as e}from"./vendor-LWJeAdU1.js";import{c as m}from"./global-CKvMKvrn.js";function c({icon:a,title:i,description:t,badge:d,eyebrow:r,breadcrumb:s,helper:l,actions:n,className:x}){return e.jsxs("div",{className:m("flex flex-col gap-4 rounded-[1.45rem] border border-white/70 bg-[linear-gradient(180deg,rgba(255,255,255,0.78)_0%,rgba(255,255,255,0.46)_100%)] p-5 shadow-[0_24px_64px_-48px_rgba(15,23,42,0.22)] backdrop-blur dark:border-white/10 dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.78)_0%,rgba(2,6,23,0.52)_100%)] dark:shadow-[0_24px_64px_-48px_rgba(0,0,0,0.7)] sm:flex-row sm:items-start sm:justify-between sm:p-6",x),children:[e.jsxs("div",{className:"min-w-0 space-y-3",children:[(r||s)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/75",children:[r?e.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 px-2.5 py-1 text-primary/80",children:r}):null,s?e.jsx("span",{children:s}):null]}),e.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[a?e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-[linear-gradient(135deg,hsl(var(--primary)/0.14),hsl(var(--primary)/0.04))] text-primary shadow-[inset_0_1px_0_rgba(255,255,255,0.68)] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.08)]",children:a}):null,e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("h1",{className:"text-[1.75rem] font-semibold tracking-[-0.03em] text-foreground",children:i}),d&&e.jsx("span",{className:"inline-flex items-center rounded-full bg-secondary px-3 py-1 text-xs font-medium text-muted-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.68)] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]",children:d})]}),t&&e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:t}),l&&e.jsx("div",{className:"inline-flex max-w-full items-center rounded-full border border-border/55 bg-background/72 px-3 py-1.5 text-xs text-muted-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.7)] dark:border-white/10 dark:bg-slate-950/42 dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",children:l})]})]})]}),n&&e.jsx("div",{className:"w-full shrink-0 self-start sm:w-auto",children:n})]})}export{c as P};
1
+ import{j as e}from"./vendor-z22RpOY0.js";import{c as m}from"./global-B-NXh5qD.js";function c({icon:a,title:i,description:t,badge:d,eyebrow:r,breadcrumb:s,helper:l,actions:n,className:x}){return e.jsxs("div",{className:m("flex flex-col gap-4 rounded-[1.45rem] border border-white/70 bg-[linear-gradient(180deg,rgba(255,255,255,0.78)_0%,rgba(255,255,255,0.46)_100%)] p-5 shadow-[0_24px_64px_-48px_rgba(15,23,42,0.22)] backdrop-blur dark:border-white/10 dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.78)_0%,rgba(2,6,23,0.52)_100%)] dark:shadow-[0_24px_64px_-48px_rgba(0,0,0,0.7)] sm:flex-row sm:items-start sm:justify-between sm:p-6",x),children:[e.jsxs("div",{className:"min-w-0 space-y-3",children:[(r||s)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground/75",children:[r?e.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 px-2.5 py-1 text-primary/80",children:r}):null,s?e.jsx("span",{children:s}):null]}),e.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[a?e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-[linear-gradient(135deg,hsl(var(--primary)/0.14),hsl(var(--primary)/0.04))] text-primary shadow-[inset_0_1px_0_rgba(255,255,255,0.68)] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.08)]",children:a}):null,e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("h1",{className:"text-[1.75rem] font-semibold tracking-[-0.03em] text-foreground",children:i}),d&&e.jsx("span",{className:"inline-flex items-center rounded-full bg-secondary px-3 py-1 text-xs font-medium text-muted-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.68)] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]",children:d})]}),t&&e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:t}),l&&e.jsx("div",{className:"inline-flex max-w-full items-center rounded-full border border-border/55 bg-background/72 px-3 py-1.5 text-xs text-muted-foreground shadow-[inset_0_1px_0_rgba(255,255,255,0.7)] dark:border-white/10 dark:bg-slate-950/42 dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",children:l})]})]})]}),n&&e.jsx("div",{className:"w-full shrink-0 self-start sm:w-auto",children:n})]})}export{c as P};
@@ -1 +1 @@
1
- import{j as s}from"./vendor-LWJeAdU1.js";import{c as x}from"./global-CKvMKvrn.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-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 +1 @@
1
- import{j as e,N as c}from"./vendor-LWJeAdU1.js";import{c as i}from"./global-CKvMKvrn.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-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};