import { useIdentity, usePresence, useReactions, useCollection } from '@deplixo/sdk'; /* @component-map * App — Main container, role switching, tab navigation [app.jsx] * QueueDisplay — Full queue list with reorder/skip/remove [components/QueueDisplay.jsx] * CurrentSinger — Current singer spotlight with timer [components/CurrentSinger.jsx] * SignUpForm — Singer sign-up form [components/SignUpForm.jsx] * HostControls — Host controls for managing the queue [components/HostControls.jsx] * AudiencePresenceIndicator — Reusable audience presence and returning-singer badge for the header and tabs. * @end-component-map */ import { useEffect, useMemo, useRef, useState } from 'react'; import { CurrentSinger } from './components/CurrentSinger.jsx'; import { SignUpForm } from './components/SignUpForm.jsx'; import { QueueDisplay } from './components/QueueDisplay.jsx'; import { HostControls } from './components/HostControls.jsx'; import { playSound } from '@deplixo/sdk'; function normalizeYouTubeTrackInput(value = '') { const raw = String(value || '').trim(); if (!raw) return ''; const idMatch = raw.match(/^[a-zA-Z0-9_-]{11}$/); if (idMatch) return raw; try { const url = new URL(raw); if (url.hostname.includes('youtu.be')) { const id = url.pathname.replace('/', '').trim(); return /^[a-zA-Z0-9_-]{11}$/.test(id) ? id : raw; } if (url.hostname.includes('youtube.com')) { const v = url.searchParams.get('v'); if (v && /^[a-zA-Z0-9_-]{11}$/.test(v)) return v; const embedMatch = url.pathname.match(/\/embed\/([a-zA-Z0-9_-]{11})/); if (embedMatch) return embedMatch[1]; } } catch { return raw; } return raw; } function getYouTubeEmbedUrl(value = '') { const normalized = normalizeYouTubeTrackInput(value); if (!normalized) return ''; if (/^https?:\/\//i.test(normalized) && !/youtu(be|\.be)/i.test(normalized)) return ''; if (/^[a-zA-Z0-9_-]{11}$/.test(normalized)) { return `https://www.youtube.com/embed/${normalized}`; } if (/youtu(be|\.be)/i.test(normalized)) { const id = normalizeYouTubeTrackInput(normalized); return /^[a-zA-Z0-9_-]{11}$/.test(id) ? `https://www.youtube.com/embed/${id}` : ''; } return ''; } function getYouTubeDisplayValue(value = '') { const normalized = normalizeYouTubeTrackInput(value); return normalized; } function YouTubeTrackEmbed({ trackValue, label = 'Backing track' }) { const embedUrl = useMemo(() => getYouTubeEmbedUrl(trackValue), [trackValue]); const displayValue = useMemo(() => getYouTubeDisplayValue(trackValue), [trackValue]); if (!displayValue) return null; return (
{label} {displayValue}
{embedUrl ? (