1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[3316],{63578(e,s,a){a.d(s,{l0:()=>l,x9:()=>r});var t=a(64577);async function l(e){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(await t.FH.get(s?"/api/data/":"/api/data/self",{params:e})).data}async function r(e){return(await t.FH.get("/api/data/users",{params:e})).data}},99170(e,s,a){a.d(s,{H:()=>r});var t=a(68413),l=a(38610);function r(e){let{systemName:s}=(0,l.R)();(0,t.useEffect)(()=>{let a=document.title;return document.title=s?`${e} - ${s}`:e,()=>{document.title=a}},[e,s])}},34335(e,s,a){a.r(s),a.d(s,{component:()=>ei});var t=a(72361),l=a(68413),r=a(2718),i=a(82799),n=a(6702),d=a(20032),c=a(29760),m=a(99170),o=a(18434),x=a(34151),u=a(67267),h=a(20769),p=a(61631),j=a(46775),g=a(1755),v=a(61309),f=a(82243),b=a(96239);function y(e){let{t:s}=(0,n.Bd)(),[a,r]=(0,l.useState)(!1),[i,d]=(0,l.useState)(e.preferences);return(0,t.jsxs)(g.lG,{open:a,onOpenChange:s=>{s&&d(e.preferences),r(s)},children:[(0,t.jsxs)(g.zM,{render:(0,t.jsx)(j.$,{variant:"outline",size:"sm"}),children:[(0,t.jsx)(p.W$k,{className:"mr-2 h-4 w-4"}),s("Preferences")]}),(0,t.jsxs)(g.Cf,{className:"sm:max-w-md",children:[(0,t.jsxs)(g.c7,{children:[(0,t.jsx)(g.L3,{children:s("Dashboard Preferences")}),(0,t.jsx)(g.rr,{children:s("Choose the default charts, range, and time granularity for model analytics.")})]}),(0,t.jsxs)("div",{className:"grid gap-4 py-2",children:[(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(v.J,{htmlFor:"default-time-range",children:s("Default range")}),(0,t.jsxs)(f.l6,{items:[...b.jX.map(e=>({value:String(e.days),label:s(e.label)}))],value:String(i.defaultTimeRangeDays),onValueChange:e=>d(s=>({...s,defaultTimeRangeDays:Number(e)})),children:[(0,t.jsx)(f.bq,{id:"default-time-range",children:(0,t.jsx)(f.yv,{placeholder:s("Select default range")})}),(0,t.jsx)(f.gC,{alignItemWithTrigger:!1,children:(0,t.jsx)(f.s3,{children:b.jX.map(e=>(0,t.jsx)(f.eb,{value:String(e.days),children:s(e.label)},e.days))})})]})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(v.J,{htmlFor:"default-time-granularity",children:s("Default time granularity")}),(0,t.jsxs)(f.l6,{items:[...b.W1.map(e=>({value:e.value,label:s(e.label)}))],value:i.defaultTimeGranularity,onValueChange:e=>d(s=>({...s,defaultTimeGranularity:e})),children:[(0,t.jsx)(f.bq,{id:"default-time-granularity",children:(0,t.jsx)(f.yv,{placeholder:s("Select time granularity")})}),(0,t.jsx)(f.gC,{alignItemWithTrigger:!1,children:(0,t.jsx)(f.s3,{children:b.W1.map(e=>(0,t.jsx)(f.eb,{value:e.value,children:s(e.label)},e.value))})})]})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(v.J,{htmlFor:"consumption-distribution-chart",children:s("Default consumption chart")}),(0,t.jsxs)(f.l6,{items:[...b.Rc.map(e=>({value:e.value,label:s(e.labelKey)}))],value:i.consumptionDistributionChart,onValueChange:e=>d(s=>({...s,consumptionDistributionChart:e})),children:[(0,t.jsx)(f.bq,{id:"consumption-distribution-chart",children:(0,t.jsx)(f.yv,{placeholder:s("Select default chart")})}),(0,t.jsx)(f.gC,{alignItemWithTrigger:!1,children:(0,t.jsx)(f.s3,{children:b.Rc.map(e=>(0,t.jsx)(f.eb,{value:e.value,children:s(e.labelKey)},e.value))})})]})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(v.J,{htmlFor:"model-analytics-chart",children:s("Default model call chart")}),(0,t.jsxs)(f.l6,{items:[...b.Z9.map(e=>({value:e.value,label:s(e.labelKey)}))],value:i.modelAnalyticsChart,onValueChange:e=>d(s=>({...s,modelAnalyticsChart:e})),children:[(0,t.jsx)(f.bq,{id:"model-analytics-chart",children:(0,t.jsx)(f.yv,{placeholder:s("Select default chart")})}),(0,t.jsx)(f.gC,{alignItemWithTrigger:!1,children:(0,t.jsx)(f.s3,{children:b.Z9.map(e=>(0,t.jsx)(f.eb,{value:e.value,children:s(e.labelKey)},e.value))})})]})]})]}),(0,t.jsx)(g.Es,{children:(0,t.jsxs)(j.$,{onClick:()=>{e.onPreferencesChange(i),r(!1)},type:"button",children:[(0,t.jsx)(p.eMP,{className:"mr-2 h-4 w-4"}),s("Save Preferences")]})})]})]})}var N=a(74400),w=a(81204),C=a(54023),k=a(3676),_=a(25207),S=a(10400);let M=e=>{let{label:s}=e;return(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"absolute inset-0 flex items-center",children:(0,t.jsx)("span",{className:"w-full border-t"})}),(0,t.jsx)("div",{className:"relative flex justify-center text-xs uppercase",children:(0,t.jsx)("span",{className:"bg-background text-muted-foreground px-2",children:s})})]})};function q(e){let{t:s}=(0,n.Bd)(),a=(0,d.n)(e=>e.auth.user),r=a?.role&&a.role>=10,[i,c]=(0,l.useState)(!1),[m,o]=(0,l.useState)(()=>(0,S.pB)(e.preferences)),[x,u]=(0,l.useState)(()=>e.preferences.defaultTimeRangeDays),h=(e,s)=>{o(a=>({...a,[e]:s})),("start_timestamp"===e||"end_timestamp"===e)&&u(null)};return(0,t.jsxs)(g.lG,{open:i,onOpenChange:s=>{s&&(o((0,S.pB)(e.preferences)),u(e.preferences.defaultTimeRangeDays)),c(s)},children:[(0,t.jsxs)(g.zM,{render:(0,t.jsx)(j.$,{variant:"outline",size:"sm"}),children:[(0,t.jsx)(p.dJT,{className:"mr-2 h-4 w-4"}),s("Filter")]}),(0,t.jsxs)(g.Cf,{className:"flex max-h-[calc(100dvh-2rem)] flex-col max-sm:h-dvh max-sm:w-screen max-sm:max-w-none max-sm:rounded-none max-sm:p-4 sm:max-w-lg",children:[(0,t.jsxs)(g.c7,{children:[(0,t.jsx)(g.L3,{children:s("Filter Dashboard Models")}),(0,t.jsx)(g.rr,{children:s("Set filters to customize your dashboard statistics and charts.")})]}),(0,t.jsx)(k.F,{className:"flex-1 pr-3 sm:pr-4",children:(0,t.jsxs)("div",{className:"grid gap-3 py-3 sm:gap-4 sm:py-4",children:[(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsxs)(v.J,{className:"flex items-center gap-2",children:[(0,t.jsx)(p.VvS,{className:"h-4 w-4"}),s("Quick Range")]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:flex",children:b.jX.map(e=>(0,t.jsx)(j.$,{type:"button",size:"sm",variant:x===e.days?"default":"outline",onClick:()=>(e=>{let{start:s,end:a}=(0,N.fj)(e);o(e=>({...e,start_timestamp:s,end_timestamp:a})),u(e)})(e.days),className:(0,w.cn)("flex-1",x===e.days&&"ring-ring ring-2 ring-offset-2"),children:s(e.label)},e.days))})]}),(0,t.jsx)(M,{label:s("Custom Time Range")}),(0,t.jsxs)("div",{className:"grid gap-3 sm:gap-4",children:[(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(v.J,{htmlFor:"start_timestamp",children:s("Start Time")}),(0,t.jsx)(_.K,{value:m.start_timestamp,onChange:e=>h("start_timestamp",e||void 0),placeholder:s("Select start time")}
1)]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(v.J,{htmlFor:"end_timestamp",children:s("End Time")}),(0,t.jsx)(_.K,{value:m.end_timestamp,onChange:e=>h("end_timestamp",e||void 0),placeholder:s("Select end time")})]})]}),(0,t.jsx)(M,{label:s("Chart Settings")}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(v.J,{htmlFor:"time_granularity",children:s("Time Granularity")}),(0,t.jsxs)(f.l6,{items:[...b.W1.map(e=>({value:e.value,label:s(e.label)}))],value:m.time_granularity,onValueChange:e=>h("time_granularity",e),children:[(0,t.jsx)(f.bq,{children:(0,t.jsx)(f.yv,{placeholder:s("Select time granularity")})}),(0,t.jsx)(f.gC,{alignItemWithTrigger:!1,children:(0,t.jsx)(f.s3,{children:b.W1.map(e=>(0,t.jsx)(f.eb,{value:e.value,children:s(e.label)},e.value))})})]})]}),r&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(M,{label:s("Admin Only")}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(v.J,{htmlFor:"username",children:s("Username")}),(0,t.jsx)(C.p,{id:"username",placeholder:s("Filter by username"),value:m.username,onChange:e=>h("username",e.target.value)})]})]})]})}),(0,t.jsxs)(g.Es,{className:"grid grid-cols-2 gap-2 sm:flex",children:[(0,t.jsxs)(j.$,{onClick:()=>{let s=e.preferences.defaultTimeRangeDays,{start:a,end:t}=(0,N.fj)(s);o({...(0,S.pB)(e.preferences),start_timestamp:a,end_timestamp:t}),u(s),e.onReset(),c(!1)},variant:"outline",type:"button",children:[(0,t.jsx)(p.Hbd,{className:"mr-2 h-4 w-4"}),s("Reset")]}),(0,t.jsxs)(j.$,{onClick:()=>{e.onFilterChange((0,S.Hl)(m)),c(!1)},type:"submit",children:[(0,t.jsx)(p.vji,{className:"mr-2 h-4 w-4"}),s("Apply Filters")]})]})]})]})}var $=a(53540),z=a(71114),A=a(3642),F=a(63578);let D=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)"],T=[{value:7,label:"Last 7 days"},{value:30,label:"Last 30 days"}];function R(e){let{t:s}=(0,n.Bd)();return(0,t.jsx)("div",{className:"bg-muted/60 inline-flex items-center gap-0.5 rounded-md p-0.5",children:T.map(a=>(0,t.jsx)(j.$,{type:"button",variant:e.value===a.value?"secondary":"ghost",size:"xs",className:(0,w.cn)("h-7 px-2.5 text-xs",e.value===a.value&&"bg-background shadow-xs"),onClick:()=>e.onChange(a.value),children:s(a.label)},a.value))})}function B(e,s){return new Intl.NumberFormat(s,{maximumFractionDigits:0}).format(Math.max(0,Math.round(e)))}function E(e,s){return new Intl.NumberFormat(s,{notation:"compact",maximumFractionDigits:1}).format(Math.max(0,Math.round(e)))}function L(e){let s=new Date(1e3*e);return`${s.getFullYear()}-${s.getMonth()+1}-${s.getDate()}`}function W(e){let s=Math.max(...e.values,1);return(0,t.jsx)("div",{className:"flex h-9 items-end gap-1","aria-hidden":"true",children:e.values.map((a,l)=>{let r=`${Math.max(12,a/s*100)}%`;return(0,t.jsx)("span",{className:(0,w.cn)("min-w-1 flex-1 rounded-t-sm",e.inverse?"bg-white/45":"bg-primary/20"),style:{height:r}},`${a}-${l}`)})})}function I(e){let s=e.icon;return(0,t.jsxs)("div",{className:(0,w.cn)("relative flex min-h-36 flex-col justify-between overflow-hidden rounded-md border p-5 transition-transform duration-200 hover:-translate-y-0.5",e.primary?"border-primary bg-primary text-primary-foreground":"border-border/70 bg-card text-foreground"),children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:(0,w.cn)("text-xs font-medium tracking-wide",e.primary?"text-primary-foreground/75":"text-text-secondary"),children:e.title}),(0,t.jsx)("p",{className:"mt-3 font-sans text-2xl font-semibold tracking-tight tabular-nums sm:text-[28px]",children:e.value})]}),(0,t.jsx)("span",{className:(0,w.cn)("flex size-10 shrink-0 items-center justify-center rounded-full",e.primary?"bg-white/15":"bg-primary/10"),children:(0,t.jsx)(s,{className:(0,w.cn)("size-5",e.primary?"text-primary-foreground":"text-primary"),"aria-hidden":"true"})})]}),(0,t.jsxs)("div",{className:"mt-5 flex items-end justify-between gap-4",children:[(0,t.jsx)("span",{className:(0,w.cn)("text-xs",e.primary?"text-primary-foreground/70":"text-text-tertiary"),children:e.caption}),(0,t.jsx)("div",{className:"w-24",children:(0,t.jsx)(W,{values:e.bars,inverse:e.primary})})]})]})}function P(e){let{t:s}=(0,n.Bd)(),a=Math.max(...e.points.map(e=>e.value),1),l=736,r=218,i=s=>12+s*l/Math.max(e.points.length-1,1),d=e=>18+r-e/a*r,c=e.points.map((e,s)=>`${i(s)},${d(e.value)}`).join(" "),m=`12,${18+r} ${c} ${12+l},${18+r}`;return e.loading?(0,t.jsx)(o.E,{className:"h-[270px] w-full rounded-md"}):e.points.length?(0,t.jsx)("div",{className:"relative h-[270px] w-full",children:(0,t.jsxs)("svg",{viewBox:"0 0 760 270",className:"h-full w-full overflow-visible",role:"img","aria-label":s("Usage trend"),children:[[0,.25,.5,.75,1].map(e=>{let s=18+r-e*r;return(0,t.jsxs)("g",{children:[(0,t.jsx)("line",{x1:12,x2:748,y1:s,y2:s,stroke:"var(--border)",strokeOpacity:"0.65",strokeDasharray:"3 5"}),(0,t.jsx)("text",{x:12,y:s-5,fill:"var(--text-tertiary)",fontSize:"10",children:E(a*e,"zh-CN")})]},e)}),(0,t.jsx)("polygon",{points:m,fill:"var(--primary)",fillOpacity:"0.11"}),(0,t.jsx)("polyline",{points:c,fill:"none",stroke:"var(--primary)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"}),e.points.map((s,a)=>(0,t.jsxs)("g",{children:[(0,t.jsx)("title",{children:`${s.label} \xb7 ${(0,A.eN)(s.value)}`}),(0,t.jsx)("circle",{cx:i(a),cy:d(s.value),r:"4",fill:"var(--card)",stroke:"var(--primary)",strokeWidth:"2",vectorEffect:"non-scaling-stroke"}),(0===a||a===e.points.length-1||a%3==0)&&(0,t.jsx)("text",{x:i(a),y:262,textAnchor:"middle",fill:"var(--text-tertiary)",fontSize:"10",children:s.label})]},s.key))]})}):(0,t.jsx)("div",{className:"text-text-tertiary flex h-[270px] items-center justify-center text-sm",children:s("No data available")})}function J(e){let{t:s}=(0,n.Bd)(),a=2*Math.PI*76,l=e.models.reduce((e,s)=>e+s.value,0);return e.loading?(0,t.jsx)(o.E,{className:"mx-auto h-44 w-44 rounded-full"}):!e.models.length||l<=0?(0,t.jsx)("div",{className:"text-text-tertiary flex h-44 items-center justify-center text-sm",children:s("No data available")}):(0,t.jsxs)("div",{className:"flex flex-col items-center",children:[(0,t.jsxs)("div",{className:"relative size-48",children:[(0,t.jsxs)("svg",{viewBox:"0 0 200 200",className:"size-full -rotate-90",children:[(0,t.jsx)("circle",{cx:"100",cy:"100",r:76,fill:"none",stroke:"var(--border)",strokeWidth:"22"}),e.models.map((s,r)=>{let i=s.value/l*a,n=e.models.slice(0,r).reduce((e,s)=>e+s.value/l*a,0);return(0,t.jsx)("circle",{cx:"100",cy:"100",r:76,fill:"none",stroke:D[r%D.length],strokeWidth:"22",strokeDasharray:`${Math.max(i-2,0)} ${a}`,strokeDashoffset:-n,strokeLinecap:"butt"},s.name)})]}),(0,t.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[(0,t.jsx)("span",{className:"font-sans text-2xl font-semibold tabular-nums",children:E(l,"zh-CN")}),(0,t.jsxs)("span",{className:"text-text-tertiary mt-1 text-xs",children:[s(e.rangeLabel),s("Requests")]})]})]}),(0,t.jsx)("div",{className:"mt-4 grid w-full grid-cols-2 gap-x-4 gap-y-2",children:e.models.map((e,s)=>(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-xs",children:[(0,t.jsx)("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:D[s%D.length]}}),(0,t.jsx)("span",{className:"text-text-secondary min-w-0 flex-1 truncate",children:e.name}),(0,t.jsxs)("span",{className:"text-text-tertiary tabular-nums",children:[Math.round(e.value/l*100),"%"]})]},e.name))})]})}function K(e){let{t:s}=(0,n.Bd)();return(0,t.jsxs)("section",{className:"border-border/70 bg-card overflow-hidden rounded-md border",children:[(0,t.jsxs)("div",{className:"border-border/60 flex items-center justify-between gap-3 border-b px-5 py-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:e.title}),(0,t.jsx)("p",{className:"text-text-tertiary mt-1 text-xs",children:s(e.rangeLabel)})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(R,{value:e.range,onChange:e.onRangeChange}),(0,t.jsxs)(z.N_,{to:"/usage-logs",className:"text-primary hidden items-center gap-1 text-xs font-medium hover:underline sm:inline-flex",children:[s("View details"),(0,t.jsx)(p.F1e,{className:"size-3.5","aria-hidden":"true"})]})]})]}),(0,t.jsxs)("div",{className:"px-5",children:[(0,t.jsxs)("div",{className:"text-text-tertiary border-border/60 grid grid-cols-[32px_minmax(0,1fr)_80px_84px] gap-3 border-b py-3 text-[11px]",children:[(0,t.jsx)("span",{children:s("Rank")}),(0,t.jsx)("span",{children:s("Model")}),(0,t.jsx)("span",{className:"text-right",children:s("Requests")}),(0,t.jsx)("span",{className:"text-right",children:s("Share")})]}),e.loading?(0,t.jsx)("div",{className:"space-y-4 py-4",children:Array.from({length:5}).map((e,s)=>(0,t.jsx)(o.E,{className:"h-5 w-full"},s))}):e.models.length?(0,t.jsx)("div",{children:e.models.map((s,a)=>{let l=e.models.reduce((e,s)=>e+s.value,0);return(0,t.jsxs)("div",{className:"border-border/50 grid grid-cols-[32px_minmax(0,1fr)_80px_84px] items-center gap-3 border-b py-3 last:border-b-0",children:[(0,t.jsx)("span",{className:(0,w.cn)("flex size-6 items-center justify-center rounded-full text-xs font-semibold",0===a?"bg-primary text-primary-foreground":"bg-muted text-text-secondary"),children:a+1}),(0,t.jsx)("span",{className:"truncate text-sm",children:s.name}),(0,t.jsx)("span",{className:"text-text-secondary text-right text-xs tabular-nums",children:E(s.value,"zh-CN")}),(0,t.jsx)("span",{className:"text-text-tertiary text-right text-xs tabular-nums",children:l?`${Math.round(s.value/l*100)}%`:"0%"})]},s.name)})}):(0,t.jsx)("p",{className:"text-text-tertiary py-8 text-center text-sm",children:s("No data available")})]})]})}function O(){let{t:e}=(0,n.Bd)(),s=[{label:e("Wallet"),description:e("Add balance"),icon:p.lTC,to:"/wallet"},{label:e("Connect with us"),description:e("Manage API keys"),icon:p.kVM,to:"/keys"},{label:e("Model Square"),description:e("Browse models and pricing"),icon:p.cC5,to:"/model-square"}];return(0,t.jsxs)("section",{className:"border-border/70 bg-card overflow-hidden rounded-md border",children:[(0,t.jsxs)("div",{className:"border-border/60 border-b px-5 py-4",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:e("Quick links")}),(0,t.jsx)("p",{className:"text-text-tertiary mt-1 text-xs",children:e("Common destinations")})]}),(0,t.jsx)("div",{className:"divide-border/50 divide-y px-5",children:s.map(e=>{let s=e.icon;return(0,t.jsxs)(z.N_,{to:e.to,className:"group flex items-center gap-3 py-3.5",children:[(0,t.jsx)("span",{className:"bg-primary/10 text-primary flex size-9 shrink-0 items-center justify-center rounded-full",children:(0,t.jsx)(s,{className:"size-4.5","aria-hidden":"true"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium",children:e.label}),(0,t.jsx)("span",{className:"text-text-tertiary mt-0.5 block truncate text-xs",children:e.description})]}),(0,t.jsx)(p.F1e,{className:"text-icon-muted group-hover:text-primary size-4 transition-colors","aria-hidden":"true"})]},e.to)})})]})}function U(){let{t:e,i18n:s}=(0,n.Bd)(),a=s.resolvedLanguage?.startsWith("zh")?"zh-CN":"en-US",r=(0,d.n)(e=>e.auth.user),[i,c]=(0,l.useState)(30),m=(0,l.useMemo)(()=>(0,N.GW)(i),[i]),o=T.find(e=>e.value===i)?.label??"Last 30 days",x=(0,$.I)({queryKey:["dashboard","domestic-overview",m.start_timestamp,m.end_timestamp],queryFn:()=>(0,F.l0)({start_timestamp:m.start_timestamp,end_timestamp:m.end_timestamp,default_time:"day"}),staleTime:3e5}),u=x.data?.data,{daily:h,models:j,totalRequests:g,activeModelCount:v}=(0,l.useMemo)(()=>{let s=new Map,a=new Map,t=0;
1(u??[]).forEach(l=>{let r=Number(l.quota)||0,i=Number(l.count)||0,n=Number(l.token_used)||0,d=L(l.created_at),c=s.get(d)??{value:0,requests:0,tokens:0};s.set(d,{value:c.value+r,requests:c.requests+i,tokens:c.tokens+n});let m=l.model_name||e("Unnamed model"),o=a.get(m)??{value:0,requests:0};a.set(m,{value:o.value+r,requests:o.requests+i}),t+=i});let l=Array.from({length:i},(e,a)=>{let t=L(Math.floor(new Date((m.end_timestamp-(i-1-a)*86400)*1e3).getTime()/1e3)),l=s.get(t)??{value:0,requests:0,tokens:0};return{key:t,label:function(e){let[,s,a]=e.split("-").map(Number);return`${s}/${a}`}(t),...l}}),r=Array.from(a,e=>{let[s,a]=e;return{name:s,...a}}).sort((e,s)=>s.value-e.value);return{daily:l,models:r.slice(0,5),totalRequests:t,activeModelCount:r.length}},[m.end_timestamp,u,i,e]),f=h.reduce((e,s)=>e+s.value,0),b=h.reduce((e,s)=>e+s.tokens,0),y=h[h.length-1]??{value:0,requests:0,tokens:0},w=h.slice(-8).map(e=>e.value),C=h.slice(-8).map(e=>e.requests),k=h.slice(-8).map(e=>e.tokens);return(0,t.jsxs)("div",{className:"mx-auto flex w-full max-w-[1920px] flex-col gap-4",children:[(0,t.jsxs)("section",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[(0,t.jsx)(I,{title:e("Account balance"),value:(0,A.eN)(r?.quota??0),caption:e("Available balance"),icon:p.lTC,primary:!0,bars:w.length?w:[1,2,3,2,4,3,5]}),(0,t.jsx)(I,{title:e("Cumulative usage"),value:(0,A.eN)(r?.used_quota??f),caption:e("All time"),icon:p.OJX,bars:w.length?w:[2,3,2,4,3,5,4]}),(0,t.jsx)(I,{title:e("Request count"),value:B(r?.request_count??g,a),caption:e("All time"),icon:p.Ilq,bars:C.length?C:[2,3,4,3,5,4,6]}),(0,t.jsx)(I,{title:e("Active models"),value:B(v,a),caption:e(o),icon:p.cC5,bars:[1,2,2,3,4,4,Math.max(4,v)]})]}),(0,t.jsxs)("section",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[(0,t.jsx)(I,{title:e("Spend today"),value:(0,A.eN)(y.value),caption:e("Since midnight"),icon:p.OJX,bars:w.length?w:[1,2,2,3,3,4,5]}),(0,t.jsx)(I,{title:e("Tokens today"),value:E(y.tokens,a),caption:e("Since midnight"),icon:p.TxX,bars:k.length?k:[2,2,3,3,4,4,5]}),(0,t.jsx)(I,{title:e("Requests today"),value:B(y.requests,a),caption:e("Since midnight"),icon:p._I2,bars:C.length?C:[2,3,3,4,4,5,5]}),(0,t.jsx)(I,{title:e("Token usage"),value:E(b,a),caption:e(o),icon:p.Ilq,bars:k.length?k:[1,2,3,3,4,5,6]})]}),(0,t.jsxs)("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.75fr)_minmax(300px,0.75fr)]",children:[(0,t.jsxs)("section",{className:"border-border/70 bg-card overflow-hidden rounded-md border",children:[(0,t.jsxs)("div",{className:"border-border/60 flex flex-wrap items-start justify-between gap-3 border-b px-5 py-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold",children:e("Usage trend")}),(0,t.jsx)("p",{className:"text-text-tertiary mt-1 text-xs",children:e("Daily quota usage")})]}),(0,t.jsx)(R,{value:i,onChange:c})]}),(0,t.jsx)("div",{className:"px-3 pt-4 pb-3 sm:px-5",children:(0,t.jsx)(P,{points:h,loading:x.isLoading})})]}),(0,t.jsxs)("section",{className:"border-border/70 bg-card overflow-hidden rounded-md border",children:[(0,t.jsxs)("div",{className:"border-border/60 flex flex-wrap items-start justify-between gap-3 border-b px-5 py-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold",children:e("Model usage share")}),(0,t.jsx)("p",{className:"text-text-tertiary mt-1 text-xs",children:e("By quota consumed")})]}),(0,t.jsx)(R,{value:i,onChange:c})]}),(0,t.jsx)("div",{className:"px-5 py-5",children:(0,t.jsx)(J,{models:j,loading:x.isLoading,rangeLabel:o})})]})]}),(0,t.jsxs)("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.4fr)_minmax(320px,0.85fr)]",children:[(0,t.jsx)(K,{title:e("Model request ranking"),models:j,loading:x.isLoading,range:i,onRangeChange:c,rangeLabel:o}),(0,t.jsx)(O,{})]})]})}function G(){return(0,t.jsx)(U,{})}var V=a(10387);let X=(0,r.GY)("/_authenticated/dashboard/$section"),H=(0,l.lazy)(()=>a.e(6719).then(a.bind(a,94114)).then(e=>({default:e.LogStatCards}))),Z=(0,l.lazy)(()=>Promise.all([a.e(3573),a.e(9243),a.e(3296)]).then(a.bind(a,67523)).then(e=>({default:e.ModelCharts}))),Q=(0,l.lazy)(()=>Promise.all([a.e(3573),a.e(8875),a.e(6249)]).then(a.bind(a,82091)).then(e=>({default:e.ConsumptionDistributionChart}))),Y=(0,l.lazy)(()=>a.e(4490).then(a.bind(a,59137)).then(e=>({default:e.PerformanceOverview}))),ee=(0,l.lazy)(()=>Promise.all([a.e(3573),a.e(1624),a.e(5982)]).then(a.bind(a,69757)).then(e=>({default:e.UserCharts})));function es(){return(0,t.jsx)("div",{className:"overflow-hidden rounded-lg border",children:(0,t.jsx)("div",{className:"divide-border/60 grid grid-cols-2 divide-x sm:grid-cols-3 lg:grid-cols-5",children:Array.from({length:5}).map((e,s)=>(0,t.jsxs)("div",{className:"px-4 py-3.5 sm:px-5 sm:py-4",children:[(0,t.jsx)(o.E,{className:"h-3.5 w-16"}),(0,t.jsx)(o.E,{className:"mt-2 h-7 w-20"}),(0,t.jsx)(o.E,{className:"mt-1.5 h-3.5 w-28"})]},s))})})}function ea(){return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b px-4 py-3 sm:px-5",children:[(0,t.jsx)(o.E,{className:"h-5 w-32"}),(0,t.jsx)(o.E,{className:"h-8 w-72"})]}),(0,t.jsx)("div",{className:"h-96 p-2",children:(0,t.jsx)(o.E,{className:"h-full w-full"})})]})}function et(){return(0,t.jsx)("div",{className:"overflow-hidden rounded-lg border",children:(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2 px-4 py-3 sm:px-5",children:[(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)(o.E,{className:"h-4 w-24"})}),Array.from({length:3}).map((e,s)=>(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(o.E,{className:"h-3 w-14"}),(0,t.jsx)(o.E,{className:"h-4 w-16"})]},s)),(0,t.jsx)("div",{className:"ml-auto flex items-center gap-2",children:Array.from({length:2}).map((e,s)=>(0,t.jsx)(o.E,{className:"h-5 w-28 rounded-full"},s))})]})})}let el={overview:{titleKey:"Usage Information"},models:{titleKey:"Model Call Analytics"},users:{titleKey:"User Analytics"}},er={overview:"Overview dashboard",models:"Model Call Analytics",users:"User Analytics"},ei=function(){let{t:e}=(0,n.Bd)(),s=(0,i.Z)(),a=X.useParams(),r=(0,d.n)(e=>e.auth.user?.role),o=a.section??V.$F,[p,j]=(0,l.useState)([]),[g,v]=(0,l.useState)(!1),[f,b]=(0,l.useState)(()=>(0,S.a2)()),[N,w]=(0,l.useState)(()=>(0,S.pB)((0,S.a2)())),C=(0,l.useCallback)(e=>{w(e)},[]),k=(0,l.useCallback)(()=>{w((0,S.pB)(f))},[f]),_=(0,l.useCallback)((e,s)=>{j(e),v(s)},[]),M=(0,l.useCallback)(e=>{b(e),w((0,S.pB)(e)),(0,S.g0)(e)},[]),$=el[o]??el.overview;(0,m.H)(e("overview"===o?"Overview":$.titleKey));let z=!!(r&&r>=c.z7.ADMIN),A=(0,l.useMemo)(()=>V.qB.filter(e=>"overview"!==e&&("users"!==e||z)),[z]),F=(0,l.useCallback)(e=>{s({to:"/dashboard/$section",params:{section:e}})},[s]),D="overview"!==o&&A.length>1,T="models"===o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(y,{preferences:f,onPreferencesChange:M}),(0,t.jsx)(q,{preferences:f,onFilterChange:C,onReset:k})]}):null;return(0,t.jsx)(u.Ni,{children:(0,t.jsx)(u.Ni.Content,{children:(0,t.jsxs)("div",{className:"space-y-3 sm:space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-1 text-sm leading-5",children:[(0,t.jsx)("span",{className:"text-text-tertiary",children:e("Overview")}),(0,t.jsx)("span",{className:"text-text-tertiary","aria-hidden":"true",children:"/"}),(0,t.jsx)("span",{className:"text-foreground font-semibold",children:e(er[o])})]}),"overview"!==o&&(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1.5 sm:gap-2",children:[D?(0,t.jsx)(x.tU,{value:o,onValueChange:F,children:(0,t.jsx)(x.j7,{className:"max-w-full flex-wrap justify-start group-data-horizontal/tabs:h-auto",children:A.map(s=>(0,t.jsx)(x.Xi,{value:s,children:e(el[s].titleKey)},s))})}):(0,t.jsx)("div",{}),null!=T&&(0,t.jsx)("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 sm:gap-2",children:T})]}),"overview"===o&&(0,t.jsx)(G,{}),"models"===o&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(h._A,{children:(0,t.jsx)(l.Suspense,{fallback:(0,t.jsx)(es,{}),children:(0,t.jsx)(H,{filters:N,onDataUpdate:_})})}),z&&(0,t.jsx)(h._A,{delay:.05,children:(0,t.jsx)(l.Suspense,{fallback:(0,t.jsx)(et,{}),children:(0,t.jsx)(Y,{})})}),(0,t.jsx)(h._A,{delay:.1,children:(0,t.jsx)(l.Suspense,{fallback:(0,t.jsx)(ea,{}),children:(0,t.jsx)(Q,{data:p,loading:g,defaultChartType:f.consumptionDistributionChart,timeGranularity:N.time_granularity||"hour"})})}),(0,t.jsx)(h._A,{delay:.15,children:(0,t.jsx)(l.Suspense,{fallback:(0,t.jsx)(ea,{}),children:(0,t.jsx)(Z,{data:p,loading:g,defaultChartTab:f.modelAnalyticsChart,timeGranularity:N.time_granularity||"hour"})})})]}),"users"===o&&(0,t.jsx)(h._A,{children:(0,t.jsx)(l.Suspense,{fallback:(0,t.jsx)(ea,{}),children:(0,t.jsx)(ee,{})})})]})})})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.