import { useTranslation } from 'react-i18next';
import { Play, Radio, Heart, ChevronRight, User, Disc3, ListMusic, Info, Sparkles, Star, Trash2, Share2 } from 'lucide-react';
import { queueSongStar } from '@/features/playback/store/pendingStarSync';
import { getMusicNetworkRuntime, useEnrichmentPrimary } from '@/music-network';
import type { Track } from '@/lib/media/trackTypes';
import { useAuthStore } from '@/store/authStore';
import { renderPresetIcon } from '@/music-network';
import StarRating from '@/ui/StarRating';
import { AddToPlaylistSubmenu } from '@/features/contextMenu/components/AddToPlaylistSubmenu';
import type { ContextMenuItemsProps } from '@/features/contextMenu/components/contextMenuItemTypes';
export default function QueueItemContextItems(props: ContextMenuItemsProps) {
const {
type, item, queueIndex,
playTrack, removeTrack, closeContextMenu,
networkLovedCache, setNetworkLovedForSong,
openSongInfo, userRatingOverrides, setKeyboardRating, keyboardRating,
playlistSubmenuOpen, setPlaylistSubmenuOpen, cancelPlaylistSubmenuCloseTimer, onPlaylistSubmenuTriggerMouseLeave,
playlistSongIds, setPlaylistSongIds,
audiomuseNavidromeEnabled,
applySongRating,
handleAction, startRadio, startInstantMix, copyShareLink, isStarred,
navigateLibrary,
} = props;
const { t } = useTranslation();
const auth = useAuthStore();
const networkPrimary = useEnrichmentPrimary();
const networkLabel = networkPrimary?.label ?? '';
const networkIcon = networkPrimary?.icon ?? 'custom';
return (
<>
{type === 'queue-item' && (() => {
const song = item as Track;
return (
<>
handleAction(() => playTrack(song, undefined, undefined, undefined, queueIndex))}>
{t('contextMenu.playNow')}
handleAction(() => {
if (queueIndex !== undefined) removeTrack(queueIndex);
})}>
{t('contextMenu.removeFromQueue')}
{ cancelPlaylistSubmenuCloseTimer(); setPlaylistSongIds([song.id]); setPlaylistSubmenuOpen(true); }}
onMouseLeave={onPlaylistSubmenuTriggerMouseLeave}
>
{t('contextMenu.addToPlaylist')}
{playlistSubmenuOpen && playlistSongIds[0] === song.id && (
{ setPlaylistSubmenuOpen(false); closeContextMenu(); }} />
)}
{song.albumId && (
handleAction(() => navigateLibrary(`/album/${song.albumId}`))}>
{t('contextMenu.openAlbum')}
)}
{song.artistId && (
handleAction(() => navigateLibrary(`/artist/${song.artistId}`))}>
{t('contextMenu.goToArtist')}
)}
handleAction(() => startRadio(song.artistId ?? song.artist, song.artist, song))}>
{t('contextMenu.startRadio')}
{audiomuseNavidromeEnabled && (
handleAction(() => startInstantMix(song))}>
{t('contextMenu.instantMix')}
)}
handleAction(() => {
queueSongStar(song.id, !isStarred(song.id, song.starred), song.serverId);
})}>
{isStarred(song.id, song.starred) ? t('contextMenu.unfavorite') : t('contextMenu.favorite')}
{auth.enrichmentPrimaryId !== null && (() => {
const loveKey = `${song.title}::${song.artist}`;
const loved = networkLovedCache[loveKey] ?? false;
return (
handleAction(() => {
const newLoved = !loved;
setNetworkLovedForSong(song.title, song.artist, newLoved);
void getMusicNetworkRuntime().setTrackLoved({ title: song.title, artist: song.artist }, newLoved);
})}>
{renderPresetIcon(networkIcon, 14)}
{loved ? t('contextMenu.networkUnlove', { provider: networkLabel }) : t('contextMenu.networkLove', { provider: networkLabel })}
);
})()}
e.stopPropagation()}
>
{ setKeyboardRating({ kind: 'song', id: song.id, value: r }); applySongRating(song.id, r); }}
ariaLabel={t('albumDetail.ratingLabel')}
/>
handleAction(() => copyShareLink('track', song.id))}>
{t('contextMenu.shareLink')}
handleAction(() => openSongInfo(song.id))}>
{t('contextMenu.songInfo')}
>
);
})()}
>
);
}