import{i as e,t}from"./jsx-runtime-ktpX_HJe.js";import{i as n,o as r}from"./LastPlayed-CtFlEIGx.js";import{i}from"./Image-iLcFsxYI.js";import{t as a}from"./ArtistLinks-B-97h-o5.js";import{i as o,r as s}from"./TopItemList-DirbLxx_.js";var c=t(),l=e=>i(`/apis/web/v1/stats`,{period:e});function u(){let{isPending:e,isError:t,data:i,error:a}=r({queryKey:[`stats`,`all_time`],queryFn:()=>l(`all_time`)}),o=`All time stats`;if(e)return(0,c.jsx)(d,{});if(t)return(0,c.jsx)(c.Fragment,{children:(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`h3`,{children:o}),(0,c.jsxs)(`p`,{className:`error`,children:[`Error: `,a.message]})]})});let s=`header-font font-bold text-xl`;return(0,c.jsxs)(`div`,{children:[(0,c.jsx)(n,{children:o}),(0,c.jsxs)(`div`,{className:`flex gap-6`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsxs)(`div`,{className:`mt-6`,children:[(0,c.jsx)(`span`,{className:s,title:Math.floor(i.minutes_listened/60)+` hours`,children:i.minutes_listened}),` `,`Minutes`]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{className:s,children:i.listen_count}),` Plays`]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{className:s,children:i.track_count}),` Tracks`]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{className:s,children:i.album_count}),` Albums`]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{className:s,children:i.artist_count}),` Artists`]})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsxs)(`div`,{className:`mt-6`,children:[(0,c.jsx)(`span`,{className:s,children:i.days_active}),` Days Active`]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{className:s,children:i.longest_streak}),` Longest Streak`]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{className:s,children:i.avg_daily_plays.toFixed(1)}),` `,`Avg. Daily Plays`]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{className:s,children:i.tracks_per_artist.toFixed(1)}),` `,`Avg. Tracks / Artist`]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{className:s,children:i.albums_per_artist.toFixed(1)}),` `,`Avg. Albums / Artist`]})]})]})]})}function d(){let e=[80,60,70,50,60];return(0,c.jsxs)(`div`,{children:[(0,c.jsx)(n,{children:`All time stats`}),(0,c.jsxs)(`div`,{className:`flex gap-6`,children:[(0,c.jsx)(`div`,{className:`mt-6 flex flex-col gap-2`,children:e.map((e,t)=>(0,c.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,c.jsx)(`div`,{className:`h-5 bg-secondary animate-pulse rounded-(--border-radius)`,style:{width:40}}),(0,c.jsx)(`div`,{className:`h-3 bg-secondary animate-pulse rounded-(--border-radius)`,style:{width:e}})]},t))}),(0,c.jsx)(`div`,{className:`mt-6 flex flex-col gap-2`,children:e.map((e,t)=>(0,c.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,c.jsx)(`div`,{className:`h-5 bg-secondary animate-pulse rounded-(--border-radius)`,style:{width:40}}),(0,c.jsx)(`div`,{className:`h-3 bg-secondary animate-pulse rounded-(--border-radius)`,style:{width:e}})]},t))})]})]})}function f({header:e,numItems:t=5}){return(0,c.jsxs)(`div`,{children:[(0,c.jsx)(n,{isOffset:!0,children:e}),(0,c.jsxs)(`div`,{className:`max-w-[350px] card animate-pulse`,children:[(0,c.jsx)(`div`,{className:`relative bg`,style:{width:348,height:350,borderRadius:`var(--border-radius) var(--border-radius) 0 0`,maskImage:`linear-gradient(to bottom, black, transparent)`,WebkitMaskImage:`linear-gradient(to bottom, black, transparent)`},children:(0,c.jsxs)(`div`,{className:`absolute bottom-10 left-5 flex flex-col gap-2`,children:[(0,c.jsx)(`div`,{className:`h-7 w-48 bg animate-pulse rounded-(--border-radius)`}),(0,c.jsx)(`div`,{className:`h-4 w-32 bg animate-pulse rounded-(--border-radius)`}),(0,c.jsx)(`div`,{className:`h-3 w-16 bg animate-pulse rounded-(--border-radius)`})]})}),(0,c.jsx)(`div`,{className:`flex flex-col items-start`,children:Array.from({length:t-1}).map((e,t)=>(0,c.jsx)(`div`,{className:`px-6 pb-6`,children:(0,c.jsx)(o,{bgColor:`bg`,size:`md`,subtitle:!0,meta:!0})},t))})]})]})}var p=e=>i(`/apis/web/v1/top/artists`,e);function m({period:t}){let i={limit:5,period:t,page:0},{isPending:a,isError:o,data:l,error:u}=r({queryKey:[`top/artists`,i],queryFn:()=>p(i)}),d=`Top artists`;return a?(0,c.jsx)(f,{header:d,numItems:5}):o?(0,c.jsxs)(`div`,{className:`w-[300px]`,children:[(0,c.jsx)(n,{to:`/chart/top/artists?period=${t}`,isOffset:!0,children:d}),(0,c.jsxs)(`p`,{className:`error`,children:[`Error: `,u.message]})]}):l.items[0]?(0,c.jsxs)(`div`,{children:[(0,c.jsx)(n,{to:`/chart/top/artists?period=${t}`,isOffset:!0,children:d}),(0,c.jsxs)(`div`,{className:`max-w-[350px] card`,children:[(0,c.jsxs)(`div`,{className:`relative`,children:[(0,c.jsx)(`img`,{src:l.items[0]?.item.image?.xl,srcSet:`${l.items[0]?.item.image?.large} 640w, ${l.items[0]?.item.image?.xl} 1000w`,sizes:`348px`,style:{borderRadius:`var(--border-radius) var(--border-radius) 0 0`},width:350,height:350,alt:l.items[0]?.item.name}),(0,c.jsx)(`div`,{className:`absolute inset-0 bg-linear-to-t`,style:{backgroundImage:`linear-gradient(to top,
              var(--color-bg-secondary) 0%,
              color-mix(in srgb, var(--color-bg-secondary) 99.4%, transparent) 2.9%,
              color-mix(in srgb, var(--color-bg-secondary) 97.4%, transparent) 6.2%,
              color-mix(in srgb, var(--color-bg-secondary) 92.6%, transparent) 10.5%,
              color-mix(in srgb, var(--color-bg-secondary) 84.4%, transparent) 15.5%,
              color-mix(in srgb, var(--color-bg-secondary) 70.8%, transparent) 21.1%,
              color-mix(in srgb, var(--color-bg-secondary) 57.8%, transparent) 27%,
              color-mix(in srgb, var(--color-bg-secondary) 42.2%, transparent) 33%,
              color-mix(in srgb, var(--color-bg-secondary) 29.2%, transparent) 38.9%,
              color-mix(in srgb, var(--color-bg-secondary) 15.6%, transparent) 44.5%,
              color-mix(in srgb, var(--color-bg-secondary) 7.4%, transparent) 49.5%,
              color-mix(in srgb, var(--color-bg-secondary) 2.6%, transparent) 53.8%,
              color-mix(in srgb, var(--color-bg-secondary) 0.6%, transparent) 57.1%,
              transparent 60%
              )`,borderRadius:`var(--border-radius) var(--border-radius) 0 0`}}),(0,c.jsxs)(`div`,{className:`absolute bottom-10 left-5`,children:[(0,c.jsx)(e,{to:`/artist/${l.items[0].item.id}`,children:(0,c.jsx)(`h5`,{className:`text-3xl font-semibold`,children:l.items[0]?.item.name})}),(0,c.jsxs)(`div`,{className:`color-fg-secondary`,children:[l.items[0]?.item.listen_count,` plays`]})]})]}),(0,c.jsx)(`div`,{className:`flex flex-col items-start`,children:l.items.slice(1).map(e=>(0,c.jsx)(`div`,{className:`px-6 pb-6`,children:(0,c.jsx)(s,{image:e.item.image,size:`md`,link:`/artist/${e.item.id}`,alt:e.item.name,title:e.item.name,meta:`${e.item.listen_count} plays`})},`top_artists_card_${e.rank}_${e.item.name}`))})]})]}):(0,c.jsxs)(`div`,{className:`w-[348px]`,children:[(0,c.jsx)(n,{to:`/chart/top/artists?period=${t}`,isOffset:!0,children:d}),(0,c.jsx)(`p`,{className:`ml-6 mt-6`,children:`Nothing to show`})]})}var h=e=>i(`/apis/web/v1/top/albums`,e);function g({period:t}){let i={limit:5,period:t,page:0},{isPending:o,isError:l,data:u,error:d}=r({queryKey:[`top/albums`,i],queryFn:()=>h(i)}),p=`Top albums`;return o?(0,c.jsx)(f,{header:p,numItems:5}):l?(0,c.jsxs)(`div`,{className:`w-[300px]`,children:[(0,c.jsx)(n,{to:`/chart/top/albums?period=${t}`,isOffset:!0,children:p}),(0,c.jsxs)(`p`,{className:`error`,children:[`Error: `,d.message]})]}):u.items[0]?(0,c.jsxs)(`div`,{children:[(0,c.jsx)(n,{to:`/chart/top/albums?period=${t}`,isOffset:!0,children:p}),(0,c.jsxs)(`div`,{className:`max-w-[350px] card`,children:[(0,c.jsxs)(`div`,{className:`relative`,children:[(0,c.jsx)(`img`,{src:u.items[0]?.item.image?.xl,srcSet:`${u.items[0]?.item.image?.large} 640w, ${u.items[0]?.item.image?.xl} 1000w`,sizes:`348px`,style:{borderRadius:`var(--border-radius) var(--border-radius) 0 0`},width:350,height:350,alt:u.items[0]?.item.title}),(0,c.jsx)(`div`,{className:`absolute inset-0 bg-linear-to-t`,style:{backgroundImage:`linear-gradient(to top,
              var(--color-bg-secondary) 0%,
              color-mix(in srgb, var(--color-bg-secondary) 99.4%, transparent) 2.9%,
              color-mix(in srgb, var(--color-bg-secondary) 97.4%, transparent) 6.2%,
              color-mix(in srgb, var(--color-bg-secondary) 92.6%, transparent) 10.5%,
              color-mix(in srgb, var(--color-bg-secondary) 84.4%, transparent) 15.5%,
              color-mix(in srgb, var(--color-bg-secondary) 70.8%, transparent) 21.1%,
              color-mix(in srgb, var(--color-bg-secondary) 57.8%, transparent) 27%,
              color-mix(in srgb, var(--color-bg-secondary) 42.2%, transparent) 33%,
              color-mix(in srgb, var(--color-bg-secondary) 29.2%, transparent) 38.9%,
              color-mix(in srgb, var(--color-bg-secondary) 15.6%, transparent) 44.5%,
              color-mix(in srgb, var(--color-bg-secondary) 7.4%, transparent) 49.5%,
              color-mix(in srgb, var(--color-bg-secondary) 2.6%, transparent) 53.8%,
              color-mix(in srgb, var(--color-bg-secondary) 0.6%, transparent) 57.1%,
              transparent 60%
              )`,borderRadius:`var(--border-radius) var(--border-radius) 0 0`}}),(0,c.jsxs)(`div`,{className:`absolute bottom-10 left-5`,children:[(0,c.jsx)(e,{to:`/album/${u.items[0].item.id}`,children:(0,c.jsx)(`h5`,{className:`text-3xl font-semibold`,children:u.items[0]?.item.title})}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(a,{artists:u.items[0]?.item.artists?[u.items[0]?.item.artists[0]]:[{id:0,name:`Unknown Artist`}]}),(0,c.jsxs)(`div`,{className:`color-fg-secondary`,children:[u.items[0]?.item.listen_count,` plays`]})]})]})]}),(0,c.jsx)(`div`,{className:`flex flex-col items-start`,children:u.items.slice(1).map(e=>(0,c.jsx)(`div`,{className:`px-6 pb-6`,children:(0,c.jsx)(s,{image:e.item.image,size:`md`,link:`/album/${e.item.id}`,title:e.item.title,alt:e.item.title,subtitle:(0,c.jsx)(a,{artists:[e.item.artists[0]]}),meta:`${e.item.listen_count} plays`})},`top_albums_card_${e.rank}_${e.item.title}`))})]})]}):(0,c.jsxs)(`div`,{className:`w-[348px]`,children:[(0,c.jsx)(n,{to:`/chart/top/albums?period=${t}`,isOffset:!0,children:p}),(0,c.jsx)(`p`,{className:`ml-6 mt-6`,children:`Nothing to show`})]})}export{m as n,u as r,g as t};