@jacshuo/onyx 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- 'use strict';var react=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),lucideReact=require('lucide-react'),jsxRuntime=require('react/jsx-runtime');function n(...o){return tailwindMerge.twMerge(clsx.clsx(o))}var V="data:image/svg+xml,"+encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200">
1
+ 'use strict';var react=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),lucideReact=require('lucide-react'),jsxRuntime=require('react/jsx-runtime');function o(...r){return tailwindMerge.twMerge(clsx.clsx(r))}var B="data:image/svg+xml,"+encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200">
2
2
  <rect width="200" height="200" fill="#1e1b2e"/>
3
3
  <circle cx="100" cy="100" r="60" fill="none" stroke="#6366f1" stroke-width="1.5" opacity="0.3"/>
4
4
  <circle cx="100" cy="100" r="20" fill="none" stroke="#6366f1" stroke-width="1" opacity="0.4"/>
5
5
  <text x="100" y="108" text-anchor="middle" font-family="monospace" font-size="18" fill="#6366f1" opacity="0.6">\u266A</text>
6
- </svg>`);function ne(o){if(!isFinite(o)||o<0)return "0:00";let R=Math.floor(o/60),p=Math.floor(o%60);return `${R}:${p.toString().padStart(2,"0")}`}function Ae(o){return o.startsWith("bottom")?"bottom":o.startsWith("top")?"top":"right"}var ze={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"},Ve={"bottom-right":"bottom-4 right-0","bottom-left":"bottom-4 left-0","top-right":"top-4 right-0","top-left":"top-4 left-0"},We={"bottom-right":"bottom-8 right-0 w-1.5 h-16 rounded-l-full","bottom-left":"bottom-8 left-0 w-1.5 h-16 rounded-r-full","top-right":"top-8 right-0 w-1.5 h-16 rounded-l-full","top-left":"top-8 left-0 w-1.5 h-16 rounded-r-full"};function et({playlist:o,initialTrack:R=0,position:p="bottom-right",entrance:re,theme:W,docked:O=false,visible:_,onVisibleChange:y,onTrackChange:B,onLike:U,autoPlay:X=true,shuffle:ae=false,loop:ie=false,accent:F="#8b5cf6",className:se}){let [a,le]=react.useState(R),[d,D]=react.useState(false),[K,$]=react.useState(0),[k,ce]=react.useState(0),[M,ue]=react.useState(.8),[b,q]=react.useState(false),[P,de]=react.useState(new Set),[me,fe]=react.useState(false),[he,j]=react.useState(_??!O),[C,H]=react.useState(false),[I,A]=react.useState(false),[g,pe]=react.useState(ae),[z,ve]=react.useState(ie),G=react.useRef(false),m=react.useRef(null),be=react.useRef(null),x=react.useRef(void 0),S=_??he,J=re??Ae(p),s=o[a],f=O,ge=W==="dark"?"dark":W==="light"?"light":"",xe="bg-(--mp-bg)",E="text-(--mp-text)",l="text-(--mp-text-muted)",T="text-(--accent)",Q="border-(--mp-border)";react.useEffect(()=>{let e=m.current;e&&(e.src=s.src,e.load(),d&&e.play().catch(()=>{}));},[a,s.src]),react.useEffect(()=>{if(!X||G.current)return;let e=m.current;if(!e)return;let r=()=>{G.current=true,D(true),e.play().catch(()=>{});};return e.addEventListener("canplaythrough",r,{once:true}),()=>e.removeEventListener("canplaythrough",r)},[X]),react.useEffect(()=>{let e=m.current;e&&(d?e.play().catch(()=>{}):e.pause());},[d]),react.useEffect(()=>{let e=m.current;e&&(e.volume=b?0:M);},[M,b]),react.useEffect(()=>{let e=m.current;if(!e)return;let r=()=>$(e.currentTime),u=()=>ce(e.duration),h=()=>{z?(e.currentTime=0,e.play().catch(()=>{})):Y();};return e.addEventListener("timeupdate",r),e.addEventListener("loadedmetadata",u),e.addEventListener("ended",h),()=>{e.removeEventListener("timeupdate",r),e.removeEventListener("loadedmetadata",u),e.removeEventListener("ended",h);}},[a,o.length]);let v=react.useCallback(e=>{let r=(e%o.length+o.length)%o.length;le(r),$(0),B?.(r,o[r]),S||(j(true),y?.(true));},[o,S,B,y]),Y=react.useCallback(()=>{if(g){let e;do e=Math.floor(Math.random()*o.length);while(e===a&&o.length>1);v(e);}else v(a+1);},[v,a,g,o.length]),we=react.useCallback(()=>{if(g){let e;do e=Math.floor(Math.random()*o.length);while(e===a&&o.length>1);v(e);}else v(a-1);},[v,a,g,o.length]),Ne=react.useCallback(()=>{let e=P.has(a);de(r=>{let u=new Set(r);return e?u.delete(a):u.add(a),u}),U?.(a,s,!e);},[a,P,U,s]),ye=react.useCallback(e=>{let r=e.currentTarget.getBoundingClientRect(),h=Math.max(0,Math.min(1,(e.clientX-r.left)/r.width))*k;m.current&&(m.current.currentTime=h),$(h);},[k]),Z=react.useCallback(()=>{H(true);let e=f?200:400;x.current=setTimeout(()=>{H(false),j(false),y?.(false);},e);},[f,y]);react.useEffect(()=>()=>{x.current&&clearTimeout(x.current);},[]);let ke=I?"fade-in 0.2s ease-out both":`mp-enter-${J} 0.45s cubic-bezier(0.16, 1, 0.3, 1) both`,Pe=I?"fade-in 0.2s ease-in reverse both":`mp-exit-${J} 0.4s cubic-bezier(0.7, 0, 0.84, 0) both`,ee=k>0?K/k*100:0;return f&&!S&&!C?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("audio",{ref:m,preload:"metadata"}),jsxRuntime.jsxs("div",{className:n("fixed z-100 cursor-pointer transition-all duration-300",We[p]),style:{"--accent":F},onMouseEnter:()=>{A(true),j(true),y?.(true);},children:[jsxRuntime.jsx("div",{className:n("h-full w-full rounded-full",d?"bg-(--accent)":"bg-(--mp-dock-strip)"),style:d?{animation:"mp-progress-glow 2s ease-in-out infinite",boxShadow:"0 0 12px color-mix(in srgb, var(--accent) 50%, transparent)"}:void 0}),d&&jsxRuntime.jsx("div",{className:"absolute inset-0 rounded-full bg-(--accent)/30",style:{animation:"mp-pulse-ring 2s ease-out infinite"}})]})]}):!S&&!C?jsxRuntime.jsx("audio",{ref:m,preload:"metadata"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("audio",{ref:m,preload:"metadata"}),jsxRuntime.jsx("div",{className:n("fixed z-100",f?Ve[p]:ze[p],ge),style:{"--accent":F,...C?{animation:Pe}:{animation:ke}},onMouseEnter:()=>{f&&(x.current&&(clearTimeout(x.current),x.current=void 0),C&&H(false),A(true));},onMouseLeave:()=>{f&&(A(false),Z());},children:jsxRuntime.jsxs("div",{className:n("w-[320px] overflow-hidden rounded-2xl border shadow-2xl backdrop-blur-xl",xe,Q,f&&"rounded-none",p.endsWith("right")&&f&&"rounded-l-2xl",p.endsWith("left")&&f&&"rounded-r-2xl",se),children:[jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 overflow-hidden",children:jsxRuntime.jsx("img",{src:s.cover||V,alt:"",className:"h-full w-full scale-110 object-cover opacity-30 blur-2xl",draggable:false})}),jsxRuntime.jsxs("div",{className:"relative flex items-center gap-3.5 p-4 pb-3",children:[jsxRuntime.jsxs("div",{className:"relative h-14 w-14 shrink-0",children:[jsxRuntime.jsxs("div",{className:"h-14 w-14 overflow-hidden rounded-full border-2 border-white/10 shadow-lg",style:d?{animation:"mp-vinyl-spin 4s linear infinite"}:void 0,children:[jsxRuntime.jsx("img",{src:s.cover||V,alt:s.album??s.title,className:"h-full w-full object-cover",draggable:false}),jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"h-3 w-3 rounded-full bg-black/60 ring-1 ring-white/10"})})]}),d&&jsxRuntime.jsx("div",{className:"absolute inset-0 rounded-full bg-(--accent)/20",style:{animation:"mp-pulse-ring 2.5s ease-out infinite"}})]}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:n("truncate text-sm font-semibold",E),children:s.title}),s.artist&&jsxRuntime.jsx("div",{className:n("truncate text-xs",l),children:s.artist}),s.album&&jsxRuntime.jsx("div",{className:n("mt-0.5 truncate text-[10px] tracking-wide",l,"opacity-60"),children:s.album})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[jsxRuntime.jsx("button",{className:n("rounded-full p-1.5 transition-all duration-200",P.has(a)?"text-rose-500 hover:text-rose-400":n(l,"hover:text-rose-500")),onClick:Ne,title:"Like",children:jsxRuntime.jsx(lucideReact.Heart,{className:"h-4 w-4",fill:P.has(a)?"currentColor":"none"})}),jsxRuntime.jsx("button",{className:n("rounded-full p-1.5 transition-colors",l,"hover:"+E.split(" ")[0]),onClick:()=>fe(e=>!e),title:"Playlist",children:jsxRuntime.jsx(lucideReact.ListMusic,{className:"h-4 w-4"})}),!f&&jsxRuntime.jsx("button",{className:n("rounded-full p-1.5 transition-colors",l,"hover:"+E.split(" ")[0]),onClick:Z,title:"Dismiss",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3.5 w-3.5"})})]})]})]}),jsxRuntime.jsxs("div",{className:"px-4",children:[jsxRuntime.jsxs("div",{ref:be,className:"group relative h-1.5 cursor-pointer rounded-full bg-(--mp-surface)",onClick:ye,children:[jsxRuntime.jsx("div",{className:"h-full rounded-full bg-(--accent) transition-[width] duration-150",style:{width:`${ee}%`}}),jsxRuntime.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-y-1/2 rounded-full bg-(--accent) opacity-0 shadow-md transition-opacity group-hover:opacity-100",style:{left:`calc(${ee}% - 6px)`}})]}),jsxRuntime.jsxs("div",{className:n("mt-1 flex justify-between text-[10px] font-mono",l),children:[jsxRuntime.jsx("span",{children:ne(K)}),jsxRuntime.jsx("span",{children:ne(k)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 pb-3 pt-1",children:[jsxRuntime.jsx("button",{className:n("rounded-full p-1.5 transition-colors",g?T:l,"hover:text-(--mp-text)"),onClick:()=>pe(e=>!e),title:g?"Shuffle On":"Shuffle Off",children:jsxRuntime.jsx(lucideReact.Shuffle,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("button",{className:n("rounded-full p-1.5 transition-colors",z?T:l,"hover:text-(--mp-text)"),onClick:()=>ve(e=>!e),title:z?"Loop On":"Loop Off",children:jsxRuntime.jsx(lucideReact.Repeat1,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("button",{className:n("rounded-full p-2 transition-colors",l,"hover:text-(--mp-text)"),onClick:we,title:"Previous",children:jsxRuntime.jsx(lucideReact.SkipBack,{className:"h-4 w-4",fill:"currentColor"})}),jsxRuntime.jsx("button",{className:n("flex h-10 w-10 items-center justify-center rounded-full transition-all duration-200","bg-(--accent) text-white shadow-lg active:scale-95"),style:{boxShadow:"0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent)"},onClick:()=>D(e=>!e),title:d?"Pause":"Play",children:d?jsxRuntime.jsx(lucideReact.Pause,{className:"h-4.5 w-4.5",fill:"currentColor"}):jsxRuntime.jsx(lucideReact.Play,{className:"h-4.5 w-4.5 translate-x-px",fill:"currentColor"})}),jsxRuntime.jsx("button",{className:n("rounded-full p-2 transition-colors",l,"hover:text-(--mp-text)"),onClick:Y,title:"Next",children:jsxRuntime.jsx(lucideReact.SkipForward,{className:"h-4 w-4",fill:"currentColor"})}),jsxRuntime.jsxs("div",{className:"ml-2 flex items-center gap-1.5",children:[jsxRuntime.jsx("button",{className:n("rounded-full p-1 transition-colors",l,"hover:text-(--mp-text)"),onClick:()=>q(e=>!e),title:b?"Unmute":"Mute",children:b||M===0?jsxRuntime.jsx(lucideReact.VolumeX,{className:"h-3.5 w-3.5"}):jsxRuntime.jsx(lucideReact.Volume2,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("input",{type:"range",min:0,max:1,step:.01,value:b?0:M,onChange:e=>{ue(Number(e.target.value)),b&&q(false);},className:"mp-volume-slider h-1 w-14 cursor-pointer appearance-none rounded-full bg-(--mp-surface) accent-(--accent)"})]})]}),jsxRuntime.jsx("div",{className:n("overflow-hidden transition-all duration-300 ease-in-out",me?"max-h-60":"max-h-0"),children:jsxRuntime.jsx("div",{className:n("border-t px-2 py-2",Q),children:jsxRuntime.jsx("div",{className:"max-h-52 space-y-0.5 overflow-y-auto",children:o.map((e,r)=>{let u=r===a;return jsxRuntime.jsxs("button",{className:n("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-all duration-200",u?"bg-(--accent)/10 dark:bg-(--accent)/15":"hover:bg-(--mp-surface-hover)"),onClick:()=>{v(r),D(true);},children:[jsxRuntime.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center",children:u&&d?jsxRuntime.jsx("div",{className:"flex items-end gap-0.5",children:[1,2,3].map(h=>jsxRuntime.jsx("div",{className:"w-0.75 rounded-full bg-(--accent)",style:{height:`${8+h*4}px`,animation:`mp-eq-bar ${.4+h*.15}s ease-in-out infinite alternate`}},h))}):u?jsxRuntime.jsx(lucideReact.Disc3,{className:n("h-4 w-4",T)}):jsxRuntime.jsx("span",{className:n("text-xs font-mono",l),children:r+1})}),jsxRuntime.jsx("div",{className:"h-8 w-8 shrink-0 overflow-hidden rounded",children:jsxRuntime.jsx("img",{src:e.cover||V,alt:"",className:"h-full w-full object-cover",draggable:false})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:n("truncate text-xs font-medium",u?T:E),children:e.title}),e.artist&&jsxRuntime.jsx("div",{className:n("truncate text-[10px]",l),children:e.artist})]}),P.has(r)&&jsxRuntime.jsx(lucideReact.Heart,{className:"h-3 w-3 shrink-0 text-rose-500",fill:"currentColor"})]},r)})})})})]})})]})}exports.MiniPlayer=et;
6
+ </svg>`);function ie(r){if(!isFinite(r)||r<0)return "0:00";let D=Math.floor(r/60),v=Math.floor(r%60);return `${D}:${v.toString().padStart(2,"0")}`}function We(r){return r.startsWith("bottom")?"bottom":r.startsWith("top")?"top":"right"}var _e={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"},Be={"bottom-right":"bottom-4 right-0","bottom-left":"bottom-4 left-0","top-right":"top-4 right-0","top-left":"top-4 left-0"},Ge={"bottom-right":"bottom-8 right-0 w-1.5 h-16 rounded-l-full","bottom-left":"bottom-8 left-0 w-1.5 h-16 rounded-r-full","top-right":"top-8 right-0 w-1.5 h-16 rounded-l-full","top-left":"top-8 left-0 w-1.5 h-16 rounded-r-full"};function ot({playlist:r,initialTrack:D=0,position:v="bottom-right",entrance:se,theme:G,docked:A=false,visible:U,onVisibleChange:M,onTrackChange:X,onLike:F,autoPlay:K=true,shuffle:le=false,loop:ce=false,accent:q="#8b5cf6",className:ue}){let [i,de]=react.useState(D),[m,$]=react.useState(false),[J,j]=react.useState(0),[P,me]=react.useState(0),[g,fe]=react.useState(.8),[h,Q]=react.useState(false),[S,he]=react.useState(new Set),[pe,ve]=react.useState(false),[ge,H]=react.useState(U??!A),[E,I]=react.useState(false),[z,V]=react.useState(false),[N,be]=react.useState(le),[W,xe]=react.useState(ce),Y=react.useRef(false),d=react.useRef(null),we=react.useRef(null),y=react.useRef(void 0),T=react.useRef(null),b=react.useRef(null),L=U??ge,Z=se??We(v),l=r[i],f=A,Ne=G==="dark"?"dark":G==="light"?"light":"",ye="bg-(--mp-bg)",R="text-(--mp-text)",c="text-(--mp-text-muted)",O="text-(--accent)",ee="border-(--mp-border)";react.useEffect(()=>{let e=d.current;e&&(e.src=l.src,e.load(),m&&e.play().catch(()=>{}));},[i,l.src]),react.useEffect(()=>{if(!K||Y.current)return;let e=d.current;if(!e)return;let n=()=>{Y.current=true,$(true),e.play().catch(()=>{});};return e.addEventListener("canplaythrough",n,{once:true}),()=>e.removeEventListener("canplaythrough",n)},[K]),react.useEffect(()=>{let e=d.current;e&&(m?e.play().catch(()=>{}):e.pause());},[m]),react.useEffect(()=>{let e=d.current;e&&(e.muted=h,b.current?b.current.gain.value=h?0:g:e.volume=g);},[g,h]),react.useEffect(()=>{let e=d.current;if(!e)return;let n=()=>j(e.currentTime),s=()=>me(e.duration),p=()=>{W?(e.currentTime=0,e.play().catch(()=>{})):te();};return e.addEventListener("timeupdate",n),e.addEventListener("loadedmetadata",s),e.addEventListener("ended",p),()=>{e.removeEventListener("timeupdate",n),e.removeEventListener("loadedmetadata",s),e.removeEventListener("ended",p);}},[i,r.length]);let x=react.useCallback(e=>{let n=(e%r.length+r.length)%r.length;de(n),j(0),X?.(n,r[n]),L||(H(true),M?.(true));},[r,L,X,M]),te=react.useCallback(()=>{if(N){let e;do e=Math.floor(Math.random()*r.length);while(e===i&&r.length>1);x(e);}else x(i+1);},[x,i,N,r.length]),ke=react.useCallback(()=>{if(N){let e;do e=Math.floor(Math.random()*r.length);while(e===i&&r.length>1);x(e);}else x(i-1);},[x,i,N,r.length]),Ce=react.useCallback(()=>{let e=S.has(i);he(n=>{let s=new Set(n);return e?s.delete(i):s.add(i),s}),F?.(i,l,!e);},[i,S,F,l]),Me=react.useCallback(e=>{let n=e.currentTarget.getBoundingClientRect(),p=Math.max(0,Math.min(1,(e.clientX-n.left)/n.width))*P;d.current&&(d.current.currentTime=p),j(p);},[P]),ne=react.useCallback(()=>{I(true);let e=f?200:400;y.current=setTimeout(()=>{I(false),H(false),M?.(false);},e);},[f,M]);react.useEffect(()=>()=>{y.current&&clearTimeout(y.current);},[]),react.useEffect(()=>()=>{T.current?.close();},[]);function _(){if(T.current||!d.current){T.current?.resume();return}try{let e=window.AudioContext??window.webkitAudioContext;if(!e)return;let n=new e,s=n.createGain();s.gain.value=h?0:g,n.createMediaElementSource(d.current).connect(s).connect(n.destination),T.current=n,b.current=s,n.resume();}catch{}}let Pe=z?"fade-in 0.2s ease-out both":`mp-enter-${Z} 0.45s cubic-bezier(0.16, 1, 0.3, 1) both`,Se=z?"fade-in 0.2s ease-in reverse both":`mp-exit-${Z} 0.4s cubic-bezier(0.7, 0, 0.84, 0) both`,oe=P>0?J/P*100:0;return f&&!L&&!E?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("audio",{ref:d,preload:"metadata",crossOrigin:"anonymous"}),jsxRuntime.jsxs("div",{className:o("fixed z-100 cursor-pointer transition-all duration-300",Ge[v]),style:{"--accent":q},onMouseEnter:()=>{V(true),H(true),M?.(true);},children:[jsxRuntime.jsx("div",{className:o("h-full w-full rounded-full",m?"bg-(--accent)":"bg-(--mp-dock-strip)"),style:m?{animation:"mp-progress-glow 2s ease-in-out infinite",boxShadow:"0 0 12px color-mix(in srgb, var(--accent) 50%, transparent)"}:void 0}),m&&jsxRuntime.jsx("div",{className:"absolute inset-0 rounded-full bg-(--accent)/30",style:{animation:"mp-pulse-ring 2s ease-out infinite"}})]})]}):!L&&!E?jsxRuntime.jsx("audio",{ref:d,preload:"metadata",crossOrigin:"anonymous"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("audio",{ref:d,preload:"metadata",crossOrigin:"anonymous"}),jsxRuntime.jsx("div",{className:o("fixed z-100",f?Be[v]:_e[v],Ne),style:{"--accent":q,...E?{animation:Se}:{animation:Pe}},onMouseEnter:()=>{f&&(y.current&&(clearTimeout(y.current),y.current=void 0),E&&I(false),V(true));},onMouseLeave:()=>{f&&(V(false),ne());},children:jsxRuntime.jsxs("div",{className:o("w-[320px] overflow-hidden rounded-2xl border shadow-2xl backdrop-blur-xl",ye,ee,f&&"rounded-none",v.endsWith("right")&&f&&"rounded-l-2xl",v.endsWith("left")&&f&&"rounded-r-2xl",ue),children:[jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("div",{className:"absolute inset-0 overflow-hidden",children:jsxRuntime.jsx("img",{src:l.cover||B,alt:"",className:"h-full w-full scale-110 object-cover opacity-30 blur-2xl",draggable:false})}),jsxRuntime.jsxs("div",{className:"relative flex items-center gap-3.5 p-4 pb-3",children:[jsxRuntime.jsxs("div",{className:"relative h-14 w-14 shrink-0",children:[jsxRuntime.jsxs("div",{className:"h-14 w-14 overflow-hidden rounded-full border-2 border-white/10 shadow-lg",style:m?{animation:"mp-vinyl-spin 4s linear infinite"}:void 0,children:[jsxRuntime.jsx("img",{src:l.cover||B,alt:l.album??l.title,className:"h-full w-full object-cover",draggable:false}),jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"h-3 w-3 rounded-full bg-black/60 ring-1 ring-white/10"})})]}),m&&jsxRuntime.jsx("div",{className:"absolute inset-0 rounded-full bg-(--accent)/20",style:{animation:"mp-pulse-ring 2.5s ease-out infinite"}})]}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:o("truncate text-sm font-semibold",R),children:l.title}),l.artist&&jsxRuntime.jsx("div",{className:o("truncate text-xs",c),children:l.artist}),l.album&&jsxRuntime.jsx("div",{className:o("mt-0.5 truncate text-[10px] tracking-wide",c,"opacity-60"),children:l.album})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[jsxRuntime.jsx("button",{className:o("rounded-full p-1.5 transition-all duration-200",S.has(i)?"text-rose-500 hover:text-rose-400":o(c,"hover:text-rose-500")),onClick:Ce,title:"Like",children:jsxRuntime.jsx(lucideReact.Heart,{className:"h-4 w-4",fill:S.has(i)?"currentColor":"none"})}),jsxRuntime.jsx("button",{className:o("rounded-full p-1.5 transition-colors",c,"hover:"+R.split(" ")[0]),onClick:()=>ve(e=>!e),title:"Playlist",children:jsxRuntime.jsx(lucideReact.ListMusic,{className:"h-4 w-4"})}),!f&&jsxRuntime.jsx("button",{className:o("rounded-full p-1.5 transition-colors",c,"hover:"+R.split(" ")[0]),onClick:ne,title:"Dismiss",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3.5 w-3.5"})})]})]})]}),jsxRuntime.jsxs("div",{className:"px-4",children:[jsxRuntime.jsxs("div",{ref:we,className:"group relative h-1.5 cursor-pointer rounded-full bg-(--mp-surface)",onClick:Me,children:[jsxRuntime.jsx("div",{className:"h-full rounded-full bg-(--accent) transition-[width] duration-150",style:{width:`${oe}%`}}),jsxRuntime.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-y-1/2 rounded-full bg-(--accent) opacity-0 shadow-md transition-opacity group-hover:opacity-100",style:{left:`calc(${oe}% - 6px)`}})]}),jsxRuntime.jsxs("div",{className:o("mt-1 flex justify-between text-[10px] font-mono",c),children:[jsxRuntime.jsx("span",{children:ie(J)}),jsxRuntime.jsx("span",{children:ie(P)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 pb-3 pt-1",children:[jsxRuntime.jsx("button",{className:o("rounded-full p-1.5 transition-colors",N?O:c,"hover:text-(--mp-text)"),onClick:()=>be(e=>!e),title:N?"Shuffle On":"Shuffle Off",children:jsxRuntime.jsx(lucideReact.Shuffle,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("button",{className:o("rounded-full p-1.5 transition-colors",W?O:c,"hover:text-(--mp-text)"),onClick:()=>xe(e=>!e),title:W?"Loop On":"Loop Off",children:jsxRuntime.jsx(lucideReact.Repeat1,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("button",{className:o("rounded-full p-2 transition-colors",c,"hover:text-(--mp-text)"),onClick:ke,title:"Previous",children:jsxRuntime.jsx(lucideReact.SkipBack,{className:"h-4 w-4",fill:"currentColor"})}),jsxRuntime.jsx("button",{className:o("flex h-10 w-10 items-center justify-center rounded-full transition-all duration-200","bg-(--accent) text-white shadow-lg active:scale-95"),style:{boxShadow:"0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent)"},onClick:()=>{_(),$(e=>!e);},title:m?"Pause":"Play",children:m?jsxRuntime.jsx(lucideReact.Pause,{className:"h-4.5 w-4.5",fill:"currentColor"}):jsxRuntime.jsx(lucideReact.Play,{className:"h-4.5 w-4.5 translate-x-px",fill:"currentColor"})}),jsxRuntime.jsx("button",{className:o("rounded-full p-2 transition-colors",c,"hover:text-(--mp-text)"),onClick:te,title:"Next",children:jsxRuntime.jsx(lucideReact.SkipForward,{className:"h-4 w-4",fill:"currentColor"})}),jsxRuntime.jsxs("div",{className:"ml-2 flex items-center gap-1.5",children:[jsxRuntime.jsx("button",{className:o("rounded-full p-1 transition-colors",c,"hover:text-(--mp-text)"),onClick:()=>{_();let e=!h;Q(e),b.current&&(b.current.gain.value=e?0:g);},title:h?"Unmute":"Mute",children:h||g===0?jsxRuntime.jsx(lucideReact.VolumeX,{className:"h-3.5 w-3.5"}):jsxRuntime.jsx(lucideReact.Volume2,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("input",{type:"range",min:0,max:1,step:.01,value:h?0:g,onChange:e=>{_();let n=Number(e.target.value);fe(n),h&&Q(false),b.current&&(b.current.gain.value=n);},className:"mp-volume-slider h-1 w-14 cursor-pointer appearance-none rounded-full bg-(--mp-surface) accent-(--accent)"})]})]}),jsxRuntime.jsx("div",{className:o("overflow-hidden transition-all duration-300 ease-in-out",pe?"max-h-60":"max-h-0"),children:jsxRuntime.jsx("div",{className:o("border-t px-2 py-2",ee),children:jsxRuntime.jsx("div",{className:"max-h-52 space-y-0.5 overflow-y-auto",children:r.map((e,n)=>{let s=n===i;return jsxRuntime.jsxs("button",{className:o("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-all duration-200",s?"bg-(--accent)/10 dark:bg-(--accent)/15":"hover:bg-(--mp-surface-hover)"),onClick:()=>{x(n),$(true);},children:[jsxRuntime.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center",children:s&&m?jsxRuntime.jsx("div",{className:"flex items-end gap-0.5",children:[1,2,3].map(p=>jsxRuntime.jsx("div",{className:"w-0.75 rounded-full bg-(--accent)",style:{height:`${8+p*4}px`,animation:`mp-eq-bar ${.4+p*.15}s ease-in-out infinite alternate`}},p))}):s?jsxRuntime.jsx(lucideReact.Disc3,{className:o("h-4 w-4",O)}):jsxRuntime.jsx("span",{className:o("text-xs font-mono",c),children:n+1})}),jsxRuntime.jsx("div",{className:"h-8 w-8 shrink-0 overflow-hidden rounded",children:jsxRuntime.jsx("img",{src:e.cover||B,alt:"",className:"h-full w-full object-cover",draggable:false})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:o("truncate text-xs font-medium",s?O:R),children:e.title}),e.artist&&jsxRuntime.jsx("div",{className:o("truncate text-[10px]",c),children:e.artist})]}),S.has(n)&&jsxRuntime.jsx(lucideReact.Heart,{className:"h-3 w-3 shrink-0 text-rose-500",fill:"currentColor"})]},n)})})})})]})})]})}exports.MiniPlayer=ot;
@@ -1,6 +1,6 @@
1
- import {useState,useRef,useEffect,useCallback}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {Heart,ListMusic,X,Shuffle,Repeat1,SkipBack,Pause,Play,SkipForward,VolumeX,Volume2,Disc3}from'lucide-react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';function n(...o){return twMerge(clsx(o))}var V="data:image/svg+xml,"+encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200">
1
+ import {useState,useRef,useEffect,useCallback}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {Heart,ListMusic,X,Shuffle,Repeat1,SkipBack,Pause,Play,SkipForward,VolumeX,Volume2,Disc3}from'lucide-react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';function o(...r){return twMerge(clsx(r))}var B="data:image/svg+xml,"+encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200">
2
2
  <rect width="200" height="200" fill="#1e1b2e"/>
3
3
  <circle cx="100" cy="100" r="60" fill="none" stroke="#6366f1" stroke-width="1.5" opacity="0.3"/>
4
4
  <circle cx="100" cy="100" r="20" fill="none" stroke="#6366f1" stroke-width="1" opacity="0.4"/>
5
5
  <text x="100" y="108" text-anchor="middle" font-family="monospace" font-size="18" fill="#6366f1" opacity="0.6">\u266A</text>
6
- </svg>`);function ne(o){if(!isFinite(o)||o<0)return "0:00";let R=Math.floor(o/60),p=Math.floor(o%60);return `${R}:${p.toString().padStart(2,"0")}`}function Ae(o){return o.startsWith("bottom")?"bottom":o.startsWith("top")?"top":"right"}var ze={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"},Ve={"bottom-right":"bottom-4 right-0","bottom-left":"bottom-4 left-0","top-right":"top-4 right-0","top-left":"top-4 left-0"},We={"bottom-right":"bottom-8 right-0 w-1.5 h-16 rounded-l-full","bottom-left":"bottom-8 left-0 w-1.5 h-16 rounded-r-full","top-right":"top-8 right-0 w-1.5 h-16 rounded-l-full","top-left":"top-8 left-0 w-1.5 h-16 rounded-r-full"};function et({playlist:o,initialTrack:R=0,position:p="bottom-right",entrance:re,theme:W,docked:O=false,visible:_,onVisibleChange:y,onTrackChange:B,onLike:U,autoPlay:X$1=true,shuffle:ae=false,loop:ie=false,accent:F="#8b5cf6",className:se}){let [a,le]=useState(R),[d,D]=useState(false),[K,$]=useState(0),[k,ce]=useState(0),[M,ue]=useState(.8),[b,q]=useState(false),[P,de]=useState(new Set),[me,fe]=useState(false),[he,j]=useState(_??!O),[C,H]=useState(false),[I,A]=useState(false),[g,pe]=useState(ae),[z,ve]=useState(ie),G=useRef(false),m=useRef(null),be=useRef(null),x=useRef(void 0),S=_??he,J=re??Ae(p),s=o[a],f=O,ge=W==="dark"?"dark":W==="light"?"light":"",xe="bg-(--mp-bg)",E="text-(--mp-text)",l="text-(--mp-text-muted)",T="text-(--accent)",Q="border-(--mp-border)";useEffect(()=>{let e=m.current;e&&(e.src=s.src,e.load(),d&&e.play().catch(()=>{}));},[a,s.src]),useEffect(()=>{if(!X$1||G.current)return;let e=m.current;if(!e)return;let r=()=>{G.current=true,D(true),e.play().catch(()=>{});};return e.addEventListener("canplaythrough",r,{once:true}),()=>e.removeEventListener("canplaythrough",r)},[X$1]),useEffect(()=>{let e=m.current;e&&(d?e.play().catch(()=>{}):e.pause());},[d]),useEffect(()=>{let e=m.current;e&&(e.volume=b?0:M);},[M,b]),useEffect(()=>{let e=m.current;if(!e)return;let r=()=>$(e.currentTime),u=()=>ce(e.duration),h=()=>{z?(e.currentTime=0,e.play().catch(()=>{})):Y();};return e.addEventListener("timeupdate",r),e.addEventListener("loadedmetadata",u),e.addEventListener("ended",h),()=>{e.removeEventListener("timeupdate",r),e.removeEventListener("loadedmetadata",u),e.removeEventListener("ended",h);}},[a,o.length]);let v=useCallback(e=>{let r=(e%o.length+o.length)%o.length;le(r),$(0),B?.(r,o[r]),S||(j(true),y?.(true));},[o,S,B,y]),Y=useCallback(()=>{if(g){let e;do e=Math.floor(Math.random()*o.length);while(e===a&&o.length>1);v(e);}else v(a+1);},[v,a,g,o.length]),we=useCallback(()=>{if(g){let e;do e=Math.floor(Math.random()*o.length);while(e===a&&o.length>1);v(e);}else v(a-1);},[v,a,g,o.length]),Ne=useCallback(()=>{let e=P.has(a);de(r=>{let u=new Set(r);return e?u.delete(a):u.add(a),u}),U?.(a,s,!e);},[a,P,U,s]),ye=useCallback(e=>{let r=e.currentTarget.getBoundingClientRect(),h=Math.max(0,Math.min(1,(e.clientX-r.left)/r.width))*k;m.current&&(m.current.currentTime=h),$(h);},[k]),Z=useCallback(()=>{H(true);let e=f?200:400;x.current=setTimeout(()=>{H(false),j(false),y?.(false);},e);},[f,y]);useEffect(()=>()=>{x.current&&clearTimeout(x.current);},[]);let ke=I?"fade-in 0.2s ease-out both":`mp-enter-${J} 0.45s cubic-bezier(0.16, 1, 0.3, 1) both`,Pe=I?"fade-in 0.2s ease-in reverse both":`mp-exit-${J} 0.4s cubic-bezier(0.7, 0, 0.84, 0) both`,ee=k>0?K/k*100:0;return f&&!S&&!C?jsxs(Fragment,{children:[jsx("audio",{ref:m,preload:"metadata"}),jsxs("div",{className:n("fixed z-100 cursor-pointer transition-all duration-300",We[p]),style:{"--accent":F},onMouseEnter:()=>{A(true),j(true),y?.(true);},children:[jsx("div",{className:n("h-full w-full rounded-full",d?"bg-(--accent)":"bg-(--mp-dock-strip)"),style:d?{animation:"mp-progress-glow 2s ease-in-out infinite",boxShadow:"0 0 12px color-mix(in srgb, var(--accent) 50%, transparent)"}:void 0}),d&&jsx("div",{className:"absolute inset-0 rounded-full bg-(--accent)/30",style:{animation:"mp-pulse-ring 2s ease-out infinite"}})]})]}):!S&&!C?jsx("audio",{ref:m,preload:"metadata"}):jsxs(Fragment,{children:[jsx("audio",{ref:m,preload:"metadata"}),jsx("div",{className:n("fixed z-100",f?Ve[p]:ze[p],ge),style:{"--accent":F,...C?{animation:Pe}:{animation:ke}},onMouseEnter:()=>{f&&(x.current&&(clearTimeout(x.current),x.current=void 0),C&&H(false),A(true));},onMouseLeave:()=>{f&&(A(false),Z());},children:jsxs("div",{className:n("w-[320px] overflow-hidden rounded-2xl border shadow-2xl backdrop-blur-xl",xe,Q,f&&"rounded-none",p.endsWith("right")&&f&&"rounded-l-2xl",p.endsWith("left")&&f&&"rounded-r-2xl",se),children:[jsxs("div",{className:"relative",children:[jsx("div",{className:"absolute inset-0 overflow-hidden",children:jsx("img",{src:s.cover||V,alt:"",className:"h-full w-full scale-110 object-cover opacity-30 blur-2xl",draggable:false})}),jsxs("div",{className:"relative flex items-center gap-3.5 p-4 pb-3",children:[jsxs("div",{className:"relative h-14 w-14 shrink-0",children:[jsxs("div",{className:"h-14 w-14 overflow-hidden rounded-full border-2 border-white/10 shadow-lg",style:d?{animation:"mp-vinyl-spin 4s linear infinite"}:void 0,children:[jsx("img",{src:s.cover||V,alt:s.album??s.title,className:"h-full w-full object-cover",draggable:false}),jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsx("div",{className:"h-3 w-3 rounded-full bg-black/60 ring-1 ring-white/10"})})]}),d&&jsx("div",{className:"absolute inset-0 rounded-full bg-(--accent)/20",style:{animation:"mp-pulse-ring 2.5s ease-out infinite"}})]}),jsxs("div",{className:"min-w-0 flex-1",children:[jsx("div",{className:n("truncate text-sm font-semibold",E),children:s.title}),s.artist&&jsx("div",{className:n("truncate text-xs",l),children:s.artist}),s.album&&jsx("div",{className:n("mt-0.5 truncate text-[10px] tracking-wide",l,"opacity-60"),children:s.album})]}),jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[jsx("button",{className:n("rounded-full p-1.5 transition-all duration-200",P.has(a)?"text-rose-500 hover:text-rose-400":n(l,"hover:text-rose-500")),onClick:Ne,title:"Like",children:jsx(Heart,{className:"h-4 w-4",fill:P.has(a)?"currentColor":"none"})}),jsx("button",{className:n("rounded-full p-1.5 transition-colors",l,"hover:"+E.split(" ")[0]),onClick:()=>fe(e=>!e),title:"Playlist",children:jsx(ListMusic,{className:"h-4 w-4"})}),!f&&jsx("button",{className:n("rounded-full p-1.5 transition-colors",l,"hover:"+E.split(" ")[0]),onClick:Z,title:"Dismiss",children:jsx(X,{className:"h-3.5 w-3.5"})})]})]})]}),jsxs("div",{className:"px-4",children:[jsxs("div",{ref:be,className:"group relative h-1.5 cursor-pointer rounded-full bg-(--mp-surface)",onClick:ye,children:[jsx("div",{className:"h-full rounded-full bg-(--accent) transition-[width] duration-150",style:{width:`${ee}%`}}),jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-y-1/2 rounded-full bg-(--accent) opacity-0 shadow-md transition-opacity group-hover:opacity-100",style:{left:`calc(${ee}% - 6px)`}})]}),jsxs("div",{className:n("mt-1 flex justify-between text-[10px] font-mono",l),children:[jsx("span",{children:ne(K)}),jsx("span",{children:ne(k)})]})]}),jsxs("div",{className:"flex items-center justify-center gap-2 px-4 pb-3 pt-1",children:[jsx("button",{className:n("rounded-full p-1.5 transition-colors",g?T:l,"hover:text-(--mp-text)"),onClick:()=>pe(e=>!e),title:g?"Shuffle On":"Shuffle Off",children:jsx(Shuffle,{className:"h-3.5 w-3.5"})}),jsx("button",{className:n("rounded-full p-1.5 transition-colors",z?T:l,"hover:text-(--mp-text)"),onClick:()=>ve(e=>!e),title:z?"Loop On":"Loop Off",children:jsx(Repeat1,{className:"h-3.5 w-3.5"})}),jsx("button",{className:n("rounded-full p-2 transition-colors",l,"hover:text-(--mp-text)"),onClick:we,title:"Previous",children:jsx(SkipBack,{className:"h-4 w-4",fill:"currentColor"})}),jsx("button",{className:n("flex h-10 w-10 items-center justify-center rounded-full transition-all duration-200","bg-(--accent) text-white shadow-lg active:scale-95"),style:{boxShadow:"0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent)"},onClick:()=>D(e=>!e),title:d?"Pause":"Play",children:d?jsx(Pause,{className:"h-4.5 w-4.5",fill:"currentColor"}):jsx(Play,{className:"h-4.5 w-4.5 translate-x-px",fill:"currentColor"})}),jsx("button",{className:n("rounded-full p-2 transition-colors",l,"hover:text-(--mp-text)"),onClick:Y,title:"Next",children:jsx(SkipForward,{className:"h-4 w-4",fill:"currentColor"})}),jsxs("div",{className:"ml-2 flex items-center gap-1.5",children:[jsx("button",{className:n("rounded-full p-1 transition-colors",l,"hover:text-(--mp-text)"),onClick:()=>q(e=>!e),title:b?"Unmute":"Mute",children:b||M===0?jsx(VolumeX,{className:"h-3.5 w-3.5"}):jsx(Volume2,{className:"h-3.5 w-3.5"})}),jsx("input",{type:"range",min:0,max:1,step:.01,value:b?0:M,onChange:e=>{ue(Number(e.target.value)),b&&q(false);},className:"mp-volume-slider h-1 w-14 cursor-pointer appearance-none rounded-full bg-(--mp-surface) accent-(--accent)"})]})]}),jsx("div",{className:n("overflow-hidden transition-all duration-300 ease-in-out",me?"max-h-60":"max-h-0"),children:jsx("div",{className:n("border-t px-2 py-2",Q),children:jsx("div",{className:"max-h-52 space-y-0.5 overflow-y-auto",children:o.map((e,r)=>{let u=r===a;return jsxs("button",{className:n("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-all duration-200",u?"bg-(--accent)/10 dark:bg-(--accent)/15":"hover:bg-(--mp-surface-hover)"),onClick:()=>{v(r),D(true);},children:[jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center",children:u&&d?jsx("div",{className:"flex items-end gap-0.5",children:[1,2,3].map(h=>jsx("div",{className:"w-0.75 rounded-full bg-(--accent)",style:{height:`${8+h*4}px`,animation:`mp-eq-bar ${.4+h*.15}s ease-in-out infinite alternate`}},h))}):u?jsx(Disc3,{className:n("h-4 w-4",T)}):jsx("span",{className:n("text-xs font-mono",l),children:r+1})}),jsx("div",{className:"h-8 w-8 shrink-0 overflow-hidden rounded",children:jsx("img",{src:e.cover||V,alt:"",className:"h-full w-full object-cover",draggable:false})}),jsxs("div",{className:"min-w-0 flex-1",children:[jsx("div",{className:n("truncate text-xs font-medium",u?T:E),children:e.title}),e.artist&&jsx("div",{className:n("truncate text-[10px]",l),children:e.artist})]}),P.has(r)&&jsx(Heart,{className:"h-3 w-3 shrink-0 text-rose-500",fill:"currentColor"})]},r)})})})})]})})]})}export{et as MiniPlayer};
6
+ </svg>`);function ie(r){if(!isFinite(r)||r<0)return "0:00";let D=Math.floor(r/60),v=Math.floor(r%60);return `${D}:${v.toString().padStart(2,"0")}`}function We(r){return r.startsWith("bottom")?"bottom":r.startsWith("top")?"top":"right"}var _e={"bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-right":"top-4 right-4","top-left":"top-4 left-4"},Be={"bottom-right":"bottom-4 right-0","bottom-left":"bottom-4 left-0","top-right":"top-4 right-0","top-left":"top-4 left-0"},Ge={"bottom-right":"bottom-8 right-0 w-1.5 h-16 rounded-l-full","bottom-left":"bottom-8 left-0 w-1.5 h-16 rounded-r-full","top-right":"top-8 right-0 w-1.5 h-16 rounded-l-full","top-left":"top-8 left-0 w-1.5 h-16 rounded-r-full"};function ot({playlist:r,initialTrack:D=0,position:v="bottom-right",entrance:se,theme:G,docked:A=false,visible:U,onVisibleChange:M,onTrackChange:X$1,onLike:F,autoPlay:K=true,shuffle:le=false,loop:ce=false,accent:q="#8b5cf6",className:ue}){let [i,de]=useState(D),[m,$]=useState(false),[J,j]=useState(0),[P,me]=useState(0),[g,fe]=useState(.8),[h,Q]=useState(false),[S,he]=useState(new Set),[pe,ve]=useState(false),[ge,H]=useState(U??!A),[E,I]=useState(false),[z,V]=useState(false),[N,be]=useState(le),[W,xe]=useState(ce),Y=useRef(false),d=useRef(null),we=useRef(null),y=useRef(void 0),T=useRef(null),b=useRef(null),L=U??ge,Z=se??We(v),l=r[i],f=A,Ne=G==="dark"?"dark":G==="light"?"light":"",ye="bg-(--mp-bg)",R="text-(--mp-text)",c="text-(--mp-text-muted)",O="text-(--accent)",ee="border-(--mp-border)";useEffect(()=>{let e=d.current;e&&(e.src=l.src,e.load(),m&&e.play().catch(()=>{}));},[i,l.src]),useEffect(()=>{if(!K||Y.current)return;let e=d.current;if(!e)return;let n=()=>{Y.current=true,$(true),e.play().catch(()=>{});};return e.addEventListener("canplaythrough",n,{once:true}),()=>e.removeEventListener("canplaythrough",n)},[K]),useEffect(()=>{let e=d.current;e&&(m?e.play().catch(()=>{}):e.pause());},[m]),useEffect(()=>{let e=d.current;e&&(e.muted=h,b.current?b.current.gain.value=h?0:g:e.volume=g);},[g,h]),useEffect(()=>{let e=d.current;if(!e)return;let n=()=>j(e.currentTime),s=()=>me(e.duration),p=()=>{W?(e.currentTime=0,e.play().catch(()=>{})):te();};return e.addEventListener("timeupdate",n),e.addEventListener("loadedmetadata",s),e.addEventListener("ended",p),()=>{e.removeEventListener("timeupdate",n),e.removeEventListener("loadedmetadata",s),e.removeEventListener("ended",p);}},[i,r.length]);let x=useCallback(e=>{let n=(e%r.length+r.length)%r.length;de(n),j(0),X$1?.(n,r[n]),L||(H(true),M?.(true));},[r,L,X$1,M]),te=useCallback(()=>{if(N){let e;do e=Math.floor(Math.random()*r.length);while(e===i&&r.length>1);x(e);}else x(i+1);},[x,i,N,r.length]),ke=useCallback(()=>{if(N){let e;do e=Math.floor(Math.random()*r.length);while(e===i&&r.length>1);x(e);}else x(i-1);},[x,i,N,r.length]),Ce=useCallback(()=>{let e=S.has(i);he(n=>{let s=new Set(n);return e?s.delete(i):s.add(i),s}),F?.(i,l,!e);},[i,S,F,l]),Me=useCallback(e=>{let n=e.currentTarget.getBoundingClientRect(),p=Math.max(0,Math.min(1,(e.clientX-n.left)/n.width))*P;d.current&&(d.current.currentTime=p),j(p);},[P]),ne=useCallback(()=>{I(true);let e=f?200:400;y.current=setTimeout(()=>{I(false),H(false),M?.(false);},e);},[f,M]);useEffect(()=>()=>{y.current&&clearTimeout(y.current);},[]),useEffect(()=>()=>{T.current?.close();},[]);function _(){if(T.current||!d.current){T.current?.resume();return}try{let e=window.AudioContext??window.webkitAudioContext;if(!e)return;let n=new e,s=n.createGain();s.gain.value=h?0:g,n.createMediaElementSource(d.current).connect(s).connect(n.destination),T.current=n,b.current=s,n.resume();}catch{}}let Pe=z?"fade-in 0.2s ease-out both":`mp-enter-${Z} 0.45s cubic-bezier(0.16, 1, 0.3, 1) both`,Se=z?"fade-in 0.2s ease-in reverse both":`mp-exit-${Z} 0.4s cubic-bezier(0.7, 0, 0.84, 0) both`,oe=P>0?J/P*100:0;return f&&!L&&!E?jsxs(Fragment,{children:[jsx("audio",{ref:d,preload:"metadata",crossOrigin:"anonymous"}),jsxs("div",{className:o("fixed z-100 cursor-pointer transition-all duration-300",Ge[v]),style:{"--accent":q},onMouseEnter:()=>{V(true),H(true),M?.(true);},children:[jsx("div",{className:o("h-full w-full rounded-full",m?"bg-(--accent)":"bg-(--mp-dock-strip)"),style:m?{animation:"mp-progress-glow 2s ease-in-out infinite",boxShadow:"0 0 12px color-mix(in srgb, var(--accent) 50%, transparent)"}:void 0}),m&&jsx("div",{className:"absolute inset-0 rounded-full bg-(--accent)/30",style:{animation:"mp-pulse-ring 2s ease-out infinite"}})]})]}):!L&&!E?jsx("audio",{ref:d,preload:"metadata",crossOrigin:"anonymous"}):jsxs(Fragment,{children:[jsx("audio",{ref:d,preload:"metadata",crossOrigin:"anonymous"}),jsx("div",{className:o("fixed z-100",f?Be[v]:_e[v],Ne),style:{"--accent":q,...E?{animation:Se}:{animation:Pe}},onMouseEnter:()=>{f&&(y.current&&(clearTimeout(y.current),y.current=void 0),E&&I(false),V(true));},onMouseLeave:()=>{f&&(V(false),ne());},children:jsxs("div",{className:o("w-[320px] overflow-hidden rounded-2xl border shadow-2xl backdrop-blur-xl",ye,ee,f&&"rounded-none",v.endsWith("right")&&f&&"rounded-l-2xl",v.endsWith("left")&&f&&"rounded-r-2xl",ue),children:[jsxs("div",{className:"relative",children:[jsx("div",{className:"absolute inset-0 overflow-hidden",children:jsx("img",{src:l.cover||B,alt:"",className:"h-full w-full scale-110 object-cover opacity-30 blur-2xl",draggable:false})}),jsxs("div",{className:"relative flex items-center gap-3.5 p-4 pb-3",children:[jsxs("div",{className:"relative h-14 w-14 shrink-0",children:[jsxs("div",{className:"h-14 w-14 overflow-hidden rounded-full border-2 border-white/10 shadow-lg",style:m?{animation:"mp-vinyl-spin 4s linear infinite"}:void 0,children:[jsx("img",{src:l.cover||B,alt:l.album??l.title,className:"h-full w-full object-cover",draggable:false}),jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:jsx("div",{className:"h-3 w-3 rounded-full bg-black/60 ring-1 ring-white/10"})})]}),m&&jsx("div",{className:"absolute inset-0 rounded-full bg-(--accent)/20",style:{animation:"mp-pulse-ring 2.5s ease-out infinite"}})]}),jsxs("div",{className:"min-w-0 flex-1",children:[jsx("div",{className:o("truncate text-sm font-semibold",R),children:l.title}),l.artist&&jsx("div",{className:o("truncate text-xs",c),children:l.artist}),l.album&&jsx("div",{className:o("mt-0.5 truncate text-[10px] tracking-wide",c,"opacity-60"),children:l.album})]}),jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[jsx("button",{className:o("rounded-full p-1.5 transition-all duration-200",S.has(i)?"text-rose-500 hover:text-rose-400":o(c,"hover:text-rose-500")),onClick:Ce,title:"Like",children:jsx(Heart,{className:"h-4 w-4",fill:S.has(i)?"currentColor":"none"})}),jsx("button",{className:o("rounded-full p-1.5 transition-colors",c,"hover:"+R.split(" ")[0]),onClick:()=>ve(e=>!e),title:"Playlist",children:jsx(ListMusic,{className:"h-4 w-4"})}),!f&&jsx("button",{className:o("rounded-full p-1.5 transition-colors",c,"hover:"+R.split(" ")[0]),onClick:ne,title:"Dismiss",children:jsx(X,{className:"h-3.5 w-3.5"})})]})]})]}),jsxs("div",{className:"px-4",children:[jsxs("div",{ref:we,className:"group relative h-1.5 cursor-pointer rounded-full bg-(--mp-surface)",onClick:Me,children:[jsx("div",{className:"h-full rounded-full bg-(--accent) transition-[width] duration-150",style:{width:`${oe}%`}}),jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-y-1/2 rounded-full bg-(--accent) opacity-0 shadow-md transition-opacity group-hover:opacity-100",style:{left:`calc(${oe}% - 6px)`}})]}),jsxs("div",{className:o("mt-1 flex justify-between text-[10px] font-mono",c),children:[jsx("span",{children:ie(J)}),jsx("span",{children:ie(P)})]})]}),jsxs("div",{className:"flex items-center justify-center gap-2 px-4 pb-3 pt-1",children:[jsx("button",{className:o("rounded-full p-1.5 transition-colors",N?O:c,"hover:text-(--mp-text)"),onClick:()=>be(e=>!e),title:N?"Shuffle On":"Shuffle Off",children:jsx(Shuffle,{className:"h-3.5 w-3.5"})}),jsx("button",{className:o("rounded-full p-1.5 transition-colors",W?O:c,"hover:text-(--mp-text)"),onClick:()=>xe(e=>!e),title:W?"Loop On":"Loop Off",children:jsx(Repeat1,{className:"h-3.5 w-3.5"})}),jsx("button",{className:o("rounded-full p-2 transition-colors",c,"hover:text-(--mp-text)"),onClick:ke,title:"Previous",children:jsx(SkipBack,{className:"h-4 w-4",fill:"currentColor"})}),jsx("button",{className:o("flex h-10 w-10 items-center justify-center rounded-full transition-all duration-200","bg-(--accent) text-white shadow-lg active:scale-95"),style:{boxShadow:"0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent)"},onClick:()=>{_(),$(e=>!e);},title:m?"Pause":"Play",children:m?jsx(Pause,{className:"h-4.5 w-4.5",fill:"currentColor"}):jsx(Play,{className:"h-4.5 w-4.5 translate-x-px",fill:"currentColor"})}),jsx("button",{className:o("rounded-full p-2 transition-colors",c,"hover:text-(--mp-text)"),onClick:te,title:"Next",children:jsx(SkipForward,{className:"h-4 w-4",fill:"currentColor"})}),jsxs("div",{className:"ml-2 flex items-center gap-1.5",children:[jsx("button",{className:o("rounded-full p-1 transition-colors",c,"hover:text-(--mp-text)"),onClick:()=>{_();let e=!h;Q(e),b.current&&(b.current.gain.value=e?0:g);},title:h?"Unmute":"Mute",children:h||g===0?jsx(VolumeX,{className:"h-3.5 w-3.5"}):jsx(Volume2,{className:"h-3.5 w-3.5"})}),jsx("input",{type:"range",min:0,max:1,step:.01,value:h?0:g,onChange:e=>{_();let n=Number(e.target.value);fe(n),h&&Q(false),b.current&&(b.current.gain.value=n);},className:"mp-volume-slider h-1 w-14 cursor-pointer appearance-none rounded-full bg-(--mp-surface) accent-(--accent)"})]})]}),jsx("div",{className:o("overflow-hidden transition-all duration-300 ease-in-out",pe?"max-h-60":"max-h-0"),children:jsx("div",{className:o("border-t px-2 py-2",ee),children:jsx("div",{className:"max-h-52 space-y-0.5 overflow-y-auto",children:r.map((e,n)=>{let s=n===i;return jsxs("button",{className:o("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-all duration-200",s?"bg-(--accent)/10 dark:bg-(--accent)/15":"hover:bg-(--mp-surface-hover)"),onClick:()=>{x(n),$(true);},children:[jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center",children:s&&m?jsx("div",{className:"flex items-end gap-0.5",children:[1,2,3].map(p=>jsx("div",{className:"w-0.75 rounded-full bg-(--accent)",style:{height:`${8+p*4}px`,animation:`mp-eq-bar ${.4+p*.15}s ease-in-out infinite alternate`}},p))}):s?jsx(Disc3,{className:o("h-4 w-4",O)}):jsx("span",{className:o("text-xs font-mono",c),children:n+1})}),jsx("div",{className:"h-8 w-8 shrink-0 overflow-hidden rounded",children:jsx("img",{src:e.cover||B,alt:"",className:"h-full w-full object-cover",draggable:false})}),jsxs("div",{className:"min-w-0 flex-1",children:[jsx("div",{className:o("truncate text-xs font-medium",s?O:R),children:e.title}),e.artist&&jsx("div",{className:o("truncate text-[10px]",c),children:e.artist})]}),S.has(n)&&jsx(Heart,{className:"h-3 w-3 shrink-0 text-rose-500",fill:"currentColor"})]},n)})})})})]})})]})}export{ot as MiniPlayer};