import{$ as A,ao as D,j as e,x as O,al as _,p as w}from"./ui-CHVy8zjG.js";import{r as t}from"./vendors-B1NZBNAx.js";import{Q as v,a as K,u as M,b as j,c as B,l as F,d as H,e as N,T as Q,S as c}from"./index-BxYEpruO.js";import{a as k}from"./query-Cm1bYAZz.js";import{R as E,B as P,C as R,X as Y,Y as q,T as G,L as X,a as g}from"./charts-D8DvJhXZ.js";import"./utils-Jd9mttLe.js";import"./react-timeago-LLfEHYGM.js";function $(o,r,n,l){return k({queryKey:[v.System,v.History,{time:o,action:r,provider:n,language:l}],queryFn:()=>K.history.stats(o,r??void 0,n?.name,l?.code2)})}const I=[{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},oe=()=>{const{data:o}=M(!0),r=j(o??[],a=>a.name),{data:n}=B(!0),l=j(n??[],a=>a.name),[m,b]=t.useState("month"),[d,S]=t.useState(null),[p,f]=t.useState(null),[h,L]=t.useState(null),x=$(m,d,h,p),{data:i}=x,C=t.useMemo(()=>{if(i){const a=i.movies.map(s=>({date:s.date,movies:s.count})),T=i.series.map(s=>({date:s.date,series:s.count}));return F.merge(a,T)}else return[]},[i]);A(`History Statistics - ${H()}`);const y=D();return e.jsx(O,{fluid:!0,px:0,className:u.container,children:e.jsxs(N,{result:x,children:[e.jsx(Q,{children:e.jsxs(_,{cols:{base:4,xs:2},children:[e.jsx(c,{placeholder:"Time...",options:U,value:m,onChange:a=>b(a??"month")}),e.jsx(c,{placeholder:"Action...",clearable:!0,options:I,value:d,onChange:S}),e.jsx(c,{...r,placeholder:"Provider...",clearable:!0,value:h,onChange:L}),e.jsx(c,{...l,placeholder:"Language...",clearable:!0,value:p,onChange:f})]})}),e.jsx(w,{className:u.chart,m:"xs",children:e.jsx(E,{children:e.jsxs(P,{className:u.chart,data:C,children:[e.jsx(R,{strokeDasharray:"4 2"}),e.jsx(Y,{dataKey:"date"}),e.jsx(q,{allowDecimals:!1}),e.jsx(G,{}),e.jsx(X,{verticalAlign:"top"}),e.jsx(g,{name:"Series",dataKey:"series",fill:y.colors.blue[4]}),e.jsx(g,{name:"Movies",dataKey:"movies",fill:y.colors.yellow[4]})]})})})]})})};export{oe as default};
