import{o as s,L as c}from"./chunk-NL6KNZEE-DfxmOBHd.js";import{k as d}from"./useTheme-CRMMMnig.js";import{x as h,b as x,y as m}from"./api-BuTqLiNI.js";import{T as o}from"./TopItemList-BRD-rnKC.js";function v(){const{isPending:r,isError:a,data:i,error:t}=d({queryKey:["stats","all_time"],queryFn:({queryKey:l})=>h(l[1])}),n="All time stats";if(r)return s.jsxs("div",{children:[s.jsx("h3",{children:n}),s.jsx("p",{children:"Loading..."})]});if(a)return s.jsx(s.Fragment,{children:s.jsxs("div",{children:[s.jsx("h3",{children:n}),s.jsxs("p",{className:"error",children:["Error: ",t.message]})]})});const e="header-font font-bold text-xl";return s.jsxs("div",{children:[s.jsx("h3",{children:n}),s.jsxs("div",{children:[s.jsx("span",{className:e,title:Math.floor(i.minutes_listened/60)+" hours",children:i.minutes_listened})," ","Minutes Listened"]}),s.jsxs("div",{children:[s.jsx("span",{className:e,children:i.listen_count})," Plays"]}),s.jsxs("div",{children:[s.jsx("span",{className:e,children:i.track_count})," Tracks"]}),s.jsxs("div",{children:[s.jsx("span",{className:e,children:i.album_count})," Albums"]}),s.jsxs("div",{children:[s.jsx("span",{className:e,children:i.artist_count})," Artists"]})]})}function N(r){const{isPending:a,isError:i,data:t,error:n}=d({queryKey:["top-albums",{limit:r.limit,period:r.period,artistId:r.artistId,page:0}],queryFn:({queryKey:l})=>x(l[1])}),e="Top albums";return a?s.jsxs("div",{className:"w-[300px]",children:[s.jsx("h3",{children:e}),s.jsx("p",{children:"Loading..."})]}):i?s.jsxs("div",{className:"w-[300px]",children:[s.jsx("h3",{children:e}),s.jsxs("p",{className:"error",children:["Error: ",n.message]})]}):s.jsxs("div",{children:[s.jsx("h3",{className:"hover:underline",children:s.jsx(c,{to:`/chart/top-albums?period=${r.period}${r.artistId?`&artist_id=${r.artistId}`:""}`,children:e})}),s.jsxs("div",{className:"max-w-[300px]",children:[s.jsx(o,{type:"album",data:t}),t.items.length<1?"Nothing to show":""]})]})}function f(r){const{isPending:a,isError:i,data:t,error:n}=d({queryKey:["top-artists",{limit:r.limit,period:r.period,page:0}],queryFn:({queryKey:l})=>m(l[1])}),e="Top artists";return a?s.jsxs("div",{className:"w-[300px]",children:[s.jsx("h3",{children:e}),s.jsx("p",{children:"Loading..."})]}):i?s.jsxs("div",{className:"w-[300px]",children:[s.jsx("h3",{children:e}),s.jsxs("p",{className:"error",children:["Error: ",n.message]})]}):s.jsxs("div",{children:[s.jsx("h3",{className:"hover:underline",children:s.jsx(c,{to:`/chart/top-artists?period=${r.period}`,children:e})}),s.jsxs("div",{className:"max-w-[300px]",children:[s.jsx(o,{type:"artist",data:t}),t.items.length<1?"Nothing to show":""]})]})}export{v as A,f as T,N as a};
