import{Z as A,an as D,j as e,z as O,aj as _,r as w}from"./ui-CHknQGjr.js";import{r}from"./vendors-Cq3VpzWh.js";import{Q as j,a as B,u as K,b as v,c as M,l as F,d as H,T as Q,S as c}from"./index-d8ctzLSl.js";import{a as k}from"./query-T7_5qeE1.js";import{R as E,B as N,C as P,X as R,Y,T as q,L as z,a as b}from"./charts-CDU_6Aua.js";import"./utils-DOXKkIi2.js";function G(n,l,a,t){return k({queryKey:[j.System,j.History,{time:n,action:l,provider:a,language:t}],queryFn:()=>B.history.stats(n,l??void 0,a==null?void 0:a.name,t==null?void 0:t.code2)})}const X=[{label:"Automatically Downloaded",value:1},{label:"Manually Downloaded",value:2},{label:"Upgraded",value:3}],U=[{label:"Last Week",value:"week"},{label:"Last Month",value:"month"},{label:"Last Trimester",value:"trimester"},{label:"Last Year",value:"year"}],W="_container_dj9ct_32",Z="_chart_dj9ct_38",u={container:W,chart:Z},ae=()=>{const{data:n}=K(!0),l=v(n??[],s=>s.name),{data:a}=M(!0),t=v(a??[],s=>s.name),[m,S]=r.useState("month"),[d,f]=r.useState(null),[h,L]=r.useState(null),[x,g]=r.useState(null),p=G(m,d,x,h),{data:i}=p,C=r.useMemo(()=>{if(i){const s=i.movies.map(o=>({date:o.date,movies:o.count})),T=i.series.map(o=>({date:o.date,series:o.count}));return F.merge(s,T)}else return[]},[i]);A("History Statistics - Bazarr");const y=D();return e.jsx(O,{fluid:!0,px:0,className:u.container,children:e.jsxs(H,{result:p,children:[e.jsx(Q,{children:e.jsxs(_,{cols:{base:4,xs:2},children:[e.jsx(c,{placeholder:"Time...",options:U,value:m,onChange:s=>S(s??"month")}),e.jsx(c,{placeholder:"Action...",clearable:!0,options:X,value:d,onChange:f}),e.jsx(c,{...l,placeholder:"Provider...",clearable:!0,value:x,onChange:g}),e.jsx(c,{...t,placeholder:"Language...",clearable:!0,value:h,onChange:L})]})}),e.jsx(w,{className:u.chart,m:"xs",children:e.jsx(E,{children:e.jsxs(N,{className:u.chart,data:C,children:[e.jsx(P,{strokeDasharray:"4 2"}),e.jsx(R,{dataKey:"date"}),e.jsx(Y,{allowDecimals:!1}),e.jsx(q,{}),e.jsx(z,{verticalAlign:"top"}),e.jsx(b,{name:"Series",dataKey:"series",fill:y.colors.blue[4]}),e.jsx(b,{name:"Movies",dataKey:"movies",fill:y.colors.yellow[4]})]})})})]})})};export{ae as default};
