const { useState, useEffect, useRef } = React; const MPATHS = { home:'M3 11.5 12 4l9 7.5M5.5 10v9.5h13V10', search:'M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14ZM20 20l-4-4', grid:'M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z', heart:'M12 20s-7-4.6-9.3-9C1 7.7 2.6 4.5 6 4.5c2 0 3.2 1.2 4 2.4.8-1.2 2-2.4 4-2.4 3.4 0 5 3.2 3.3 6.5C19 15.4 12 20 12 20Z', heartFill:'M12 20s-7-4.6-9.3-9C1 7.7 2.6 4.5 6 4.5c2 0 3.2 1.2 4 2.4.8-1.2 2-2.4 4-2.4 3.4 0 5 3.2 3.3 6.5C19 15.4 12 20 12 20Z', clock:'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18ZM12 7v5l3.5 2', gear:'M12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6ZM19.4 13a7.8 7.8 0 0 0 0-2l2-1.5-2-3.4-2.3 1a7.6 7.6 0 0 0-1.7-1l-.3-2.6H10.9l-.3 2.6a7.6 7.6 0 0 0-1.7 1l-2.3-1-2 3.4L4.6 11a7.8 7.8 0 0 0 0 2l-2 1.5 2 3.4 2.3-1a7.6 7.6 0 0 0 1.7 1l.3 2.6h4.2l.3-2.6a7.6 7.6 0 0 0 1.7-1l2.3 1 2-3.4Z', play:'M8 5v14l11-7z', pause:'M7 5h4v14H7zM13 5h4v14h-4z', plus:'M12 5v14M5 12h14', check:'M5 12l5 5 9-11', back:'M9 6l6 6-6 6', chevDown:'M6 9l6 6 6-6', x:'M6 6l12 12M18 6L6 18', skipBack:'M11 6V2L5 7l6 5V8a6 6 0 1 1-6 6H3a8 8 0 1 0 8-8Z', skipFwd:'M13 6V2l6 5-6 5V8a6 6 0 1 0 6 6h2a8 8 0 1 1-8-8Z', track:'M6 6l6 6-6 6M14 6l6 6-6 6', expand:'M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5', }; function MIcon({name, style, className}){ const fill = ['play','pause','heartFill'].includes(name); return ( ); } function StarIcon({style}){ return ; } function MPoster({item, wide, children}){ const [err,setErr]=useState(false); const src = wide ? (item.banner||item.cover) : item.cover; const ok = src && !err; return (
{ok ? setErr(true)} /> :
{(item.title||'?')[0]}
} {children}
); } const TYPE_LABEL = { anime:'أنمي', tv:'مسلسل', movie:'فيلم' }; function MCard({item, onClick, showProgress}){ return (
{TYPE_LABEL[item.type]} {showProgress>0 &&
}
{item.title}
{item.year} · {item.type==='movie'?`${item.runtime} د`:`م${item.seasons}`}
); } function Rail({title, sub, items, onOpen, renderExtra}){ if(!items.length) return null; return (
{title}{sub && {sub}}
{items.map(it=> onOpen(it.anime||it)} showProgress={it.progress} />)}
); } const TABS = [ {id:'home', label:'الرئيسية', icon:'home'}, {id:'categories', label:'التصنيفات', icon:'grid'}, {id:'library', label:'مكتبتي', icon:'heart'}, {id:'settings', label:'الإعدادات', icon:'gear'}, ]; function TabBar({active, onGo}){ return (
{TABS.map(t=>(
onGo(t.id)}> {t.label}
))}
); } function Header({title, onBack, onSearch}){ return (
{onBack ?
:
MYTV
} {title && {title}}
{onSearch &&
}
); } function Sheet({title, onClose, children}){ return (
e.stopPropagation()}>
{title}
{children}
); } Object.assign(window, { MIcon, StarIcon, MPoster, MCard, Rail, TabBar, Header, Sheet, TYPE_LABEL });