import{ag as t,ao as A,as as D,ac as e,p as O,V as _,i as w}from"./ui-BXZpfH9y.js";import{Q as v,c as K,j as M,h as j,g as B,l as F,u as H,a as N,T as Q,S as c}from"./index-rFIYtLBM.js";import{j as k}from"./query-DAuHJYEB.js";import{R as E,a as P,C as R,X as Y,Y as q,T as G,L as X,B as g}from"./charts-DVW70l7S.js";import"./utils-DDGcXcHy.js";import"./socket.io-parser-DoSk7wIg.js";import"./vendors-B-KVoxRZ.js";import"./react-timeago-SqGgCYKX.js";function I(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 U=[{label:"Automatically Downloaded",value:1},{label:"Manually Downloaded",value:2},{label:"Upgraded",value:3}],V=[{label:"Last Week",value:"week"},{label:"Last Month",value:"month"},{label:"Last Trimester",value:"trimester"},{label:"Last Year",value:"year"}],W="_container_dj9ct_32",$="_chart_dj9ct_38",u={container:W,chart:$},re=()=>{const{data:o}=M(!0),r=j(o??[],a=>a.name),{data:n}=B(!0),l=j(n??[],a=>a.name),[m,S]=t.useState("month"),[d,b]=t.useState(null),[p,f]=t.useState(null),[h,L]=t.useState(null),x=I(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:V,value:m,onChange:a=>S(a??"month")}),e.jsx(c,{placeholder:"Action...",clearable:!0,options:U,value:d,onChange:b}),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{re as default};
