import{I as e,i as t,t as n,z as r}from"./jsx-runtime-ktpX_HJe.js";import{t as i}from"./react-dom-C3JEgPx4.js";import{i as a}from"./LastPlayed-CtFlEIGx.js";import{t as o}from"./Image-iLcFsxYI.js";import{t as s}from"./createLucideIcon-x9JrQxsp.js";var c=s(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),l=s(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),u=r(e(),1),d=n();function f(e){return(0,d.jsxs)(t,{to:e.to,className:`px-3 py-2 flex gap-3 items-center hover:text-(--color-fg-secondary)`,onClick:e.onClick,children:[(0,d.jsx)(o,{src:e.img,size:e.imgSize?e.imgSize:100,alt:e.text}),(0,d.jsxs)(`div`,{children:[e.text,e.subtext?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`br`,{}),(0,d.jsx)(`span`,{className:`color-fg-secondary`,children:e.subtext})]}):``]})]})}function p(e){return(0,d.jsx)(t,{to:e.to,className:`flex gap-3 items-center w-fit`,onClick:e.onClick,children:(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(`img`,{src:e.img,style:{borderRadius:`var(--border-radius)`},width:150,height:150}),(0,d.jsx)(`div`,{className:`absolute inset-0 border`,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)`}}),(0,d.jsx)(`div`,{className:`absolute bottom-3 left-3`,children:(0,d.jsx)(`h5`,{className:`text-xl font-semibold line-clamp-2`,children:e.text})})]})})}function m(e){return(0,d.jsxs)(`button`,{className:`px-3 py-4 flex gap-3 items-center hover:text-(--color-fg-secondary) rounded-(--border-radius) hover:cursor-pointer w-full`,style:{border:e.active?`1px solid var(--color-fg-tertiary`:``},onClick:e.onClick,children:[(0,d.jsx)(o,{src:e.img,size:75,alt:e.text}),(0,d.jsxs)(`div`,{className:`flex justify-between items-center w-full`,children:[(0,d.jsxs)(`div`,{className:`flex flex-col items-start text-start`,children:[e.text,e.subtext?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`br`,{}),(0,d.jsx)(`span`,{className:`color-fg-secondary`,children:e.subtext})]}):``]}),e.active?(0,d.jsx)(`div`,{className:`px-2`,children:(0,d.jsx)(c,{size:24})}):``]})]})}function h({isOffset:e,children:n,to:r,className:i}){let a=e?24:0,o=`text-(--color-fg-secondary) inline-block sm:mb-3 mb-2 ${i}`;return r?(0,d.jsx)(t,{to:r,className:`${o} hover:text-(--color-fg) group`,children:(0,d.jsxs)(`h3`,{style:{marginLeft:a||0},className:`hover:cursor-pointer`,children:[n,(0,d.jsx)(`span`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:r?` →`:``})]})}):(0,d.jsx)(`h3`,{style:{marginLeft:a||0},className:o,children:n})}function g({data:e,onSelect:t,selectorMode:n}){let[r,i]=(0,u.useState)(0),o=(e,n)=>{r===n?(i(0),t({id:0,title:``})):(i(n),t({id:n,title:e}))};if(!e)return(0,d.jsx)(d.Fragment,{});let s=(e,t)=>(0,d.jsxs)(`div`,{className:`mt-2 sm:mt-4`,children:[n?(0,d.jsx)(`h3`,{className:`mt-4 mb-2`,children:e}):(0,d.jsx)(a,{isOffset:!0,children:e}),(0,d.jsx)(`div`,{className:n?`flex flex-col items-start bg rounded w-full`:`border bg-secondary rounded-(--border-radius) p-4 w-full`,children:t})]});return(0,d.jsxs)(`div`,{className:`w-full`,children:[e.artists&&e.artists.length>0&&s(`Artists`,(0,d.jsx)(`div`,{className:`p-2 flex flex-wrap gap-2 sm:gap-4`,children:e.artists.map(e=>n?(0,d.jsx)(m,{id:e.id,onClick:()=>o(e.name,e.id),text:e.name,img:e.image.small,active:r===e.id},e.id):(0,d.jsx)(p,{to:`/artist/${e.id}`,onClick:()=>t(e.id),text:e.name,img:e.image.small},e.id))})),e.albums&&e.albums.length>0&&s(`Albums`,e.albums.map(e=>n?(0,d.jsx)(m,{id:e.id,onClick:()=>o(e.title,e.id),text:e.title,subtext:e.is_various_artists?`Various Artists`:e.artists[0].name,img:e.image.small,active:r===e.id},e.id):(0,d.jsx)(f,{to:`/album/${e.id}`,onClick:()=>t(e.id),text:e.title,subtext:e.is_various_artists?`Various Artists`:e.artists[0].name,img:e.image.small},e.id))),e.tracks&&e.tracks.length>0&&s(`Tracks`,e.tracks.map(e=>n?(0,d.jsx)(m,{id:e.id,onClick:()=>o(e.title,e.id),text:e.title,subtext:e.artists.map(e=>e.name).join(`, `),img:e.image.small,active:r===e.id},e.id):(0,d.jsx)(f,{to:`/track/${e.id}`,onClick:()=>t(e.id),text:e.title,subtext:e.artists.map(e=>e.name).join(`, `),img:e.image.small,imgSize:75},e.id)))]})}var _=r(i(),1);function v({isOpen:e,onClose:t,children:n,maxW:r,h:i}){let a=(0,u.useRef)(null),[o,s]=(0,u.useState)(e),[c,l]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{if(e)s(!0),l(!1);else if(o){l(!0);let e=setTimeout(()=>{s(!1)},100);return()=>clearTimeout(e)}},[e,o]),(0,u.useEffect)(()=>{let n=e=>{if(e.key===`Escape`)t();else if(e.key===`Tab`&&a.current){let t=a.current.querySelectorAll(`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`),n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&i===n?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r?(e.preventDefault(),n.focus()):Array.from(t).find(e=>e.isEqualNode(i))||(e.preventDefault(),n.focus())}};return e&&document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),(0,u.useEffect)(()=>{let n=e=>{a.current&&!a.current.contains(e.target)&&t()};return e&&document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e,t]),o?_.createPortal((0,d.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/90 transition-opacity duration-100 ${c?`animate-fade-out`:`animate-fade-in`}`,children:(0,d.jsxs)(`div`,{ref:a,className:`border bg-secondary rounded-(--border-radius) p-6 w-full relative max-h-4/5 overflow-y-auto transition-all duration-100 ${c?`animate-fade-out-scale`:`animate-fade-in-scale`}`,style:{maxWidth:r??600,height:i??``},children:[n,(0,d.jsx)(`button`,{onClick:t,className:`absolute text-xl top-1 right-2 sm:top-3 sm:right-4 text-(--color-fg-tertiary) hover:text-(--color-fg) hover:cursor-pointer`,children:`×`})]})}),document.body):null}export{l as i,g as n,h as r,v as t};