import React, { useState, useEffect, useRef, useMemo } from 'react'; import { createRoot } from 'react-dom/client'; import { GoogleGenAI } from "@google/genai"; import { initializeApp } from "https://www.gstatic.com/firebasejs/11.10.0/firebase-app.js"; import { getAuth, signInWithEmailAndPassword, onAuthStateChanged, signOut, setPersistence, browserLocalPersistence, sendPasswordResetEmail } from "https://www.gstatic.com/firebasejs/11.10.0/firebase-auth.js"; import { getFirestore, doc, getDoc, updateDoc, arrayUnion, arrayRemove, setDoc } from "https://www.gstatic.com/firebasejs/11.10.0/firebase-firestore.js"; import { Play, Info, Search, ChevronRight, ChevronLeft, X, Loader2, LogOut, Check, Star, SlidersHorizontal, Home, Bookmark, CheckCircle, PlayCircle, Eye, EyeOff } from 'lucide-react'; // --- Firebase Configuration --- const firebaseConfig = { apiKey: "AIzaSyDECpHC2RJw5yf0soUdLdBjFAGHidlEoB8", authDomain: "army-tv-408b0.firebaseapp.com", projectId: "army-tv-408b0" }; const app = initializeApp(firebaseConfig); const auth = getAuth(app); const db = getFirestore(app); const CONTENT_API = 'https://sheet2api.com/v1/hM8tf8qUS2Wj/conteudos-bts-bangtannow'; const AVATARS: Record = { rm:"https://bangtannow.com/wp-content/uploads/2025/01/Kim-Namjoon-2.jpg", jin:"https://bangtannow.com/wp-content/uploads/2025/01/Kim-Seokjin-1.jpg", suga:"https://bangtannow.com/wp-content/uploads/2025/01/Min-Yoongi.jpg", "j-hope":"https://bangtannow.com/wp-content/uploads/2025/01/Jung-Hoseok.jpg", jimin:"https://bangtannow.com/wp-content/uploads/2025/01/Park-Jimin.jpg", v:"https://bangtannow.com/wp-content/uploads/2025/01/Kim-Taehyung.jpg", jungkook:"https://bangtannow.com/wp-content/uploads/2025/01/Jeon-Jungkook.jpg", bts:"https://i.imgur.com/brTJR6X.png", koya: "https://i.imgur.com/8eTGXzV.png", rj: "https://i.imgur.com/5N8Sm6v.png", shooky: "https://i.imgur.com/OcvNgyg.png", mang: "https://i.imgur.com/gPU6T75.png", chimmy: "https://i.imgur.com/SUO4HlP.png", tata: "https://i.imgur.com/kE02Emw.png", cooky: "https://i.imgur.com/ofR4Znl.png", bt21: "https://i.imgur.com/CtTegOi.png", van: "https://i.imgur.com/rcSYbNG.png", wootteo: "https://i.imgur.com/a2S7P3D.png", whamii: "https://i.imgur.com/R0ZOhpM.png", }; const CATEGORIES_CONFIG = [ { id: 'bastidores', title: 'Bastidores' }, { id: 'dance practice', title: 'Dance Practice' }, { id: 'entrevista', title: 'Entrevistas' }, { id: 'fanmeeting', title: 'Fanmeeting e Autógrafos' }, { id: 'documentário', title: 'Filmes e Documentários' }, { id: 'live', title: 'Live e Vlogs' }, { id: 'muster', title: 'Muster' }, { id: 'mv', title: 'MVs' }, { id: 'premiacao', title: 'Premiações' }, { id: 'programa', title: 'Programas' }, { id: 'performance', title: 'Performance' }, { id: 'reality', title: 'Reality Shows e Variedades' }, { id: 'fotos', title: 'Sessão de Fotos' }, { id: 'show', title: 'Shows e Turnês' }, { id: 'outros', title: 'Outros' } ]; const MEMBERS_LIST = ['RM', 'Jin', 'SUGA', 'j-hope', 'Jimin', 'V', 'Jung Kook', 'BTS']; interface ContentItem { TITULO: string; DESCRIÇÃO: string; IMAGEM: string; LINK: string; DATA: string; CATEGORIAS: string; MEMBROS: string; ANOS: string | number; } const parseDate = (dateStr: string) => { if (!dateStr) return new Date(0); const [day, month, year] = dateStr.split('/').map(Number); return new Date(year, month - 1, day); }; const NetflixCard = ({ item, onOpen, isFavorite, isWatched, onToggleFavorite, onToggleWatched }: any) => { return (
{item.TITULO}
{isFavorite && (
)} {isWatched && (
)}

{item.TITULO}

); }; const Row = ({ title, items, ...cardProps }: any) => { const scrollRef = useRef(null); const scroll = (dir: 'L' | 'R') => { if (scrollRef.current) { const offset = dir === 'L' ? -400 : 400; scrollRef.current.scrollBy({ left: offset, behavior: 'smooth' }); } }; if (items.length === 0) return null; return (

{title}

{items.map((item: any, idx: number) => ( ))}
); }; const HeroSlider = ({ items, onOpenModal }: { items: ContentItem[], onOpenModal: (item: ContentItem) => void }) => { const [current, setCurrent] = useState(0); useEffect(() => { const timer = setInterval(() => setCurrent(prev => (prev + 1) % items.length), 8000); return () => clearInterval(timer); }, [items.length]); if (items.length === 0) return null; return (
{items.map((item, idx) => (
{item.TITULO}
Lançamento {item.DATA}

{item.TITULO}

{item.DESCRIÇÃO}

))}
{items.map((_, idx) => (
); }; function App() { const [user, setUser] = useState(null); const [profile, setProfile] = useState(localStorage.getItem('selectedProfile')); const [authLoading, setAuthLoading] = useState(true); const [isFetching, setIsFetching] = useState(false); const [content, setContent] = useState([]); const [favorites, setFavorites] = useState([]); const [watched, setWatched] = useState([]); const [searchTerm, setSearchTerm] = useState(''); const [selectedItem, setSelectedItem] = useState(null); const [activeTab, setActiveTab] = useState('home'); const [showFilters, setShowFilters] = useState(false); const [filterMember, setFilterMember] = useState(''); const [filterYear, setFilterYear] = useState(''); const [filterCat, setFilterCat] = useState(''); const [showPassword, setShowPassword] = useState(false); useEffect(() => { return onAuthStateChanged(auth, async (u) => { if (u) { setUser(u); const docSnap = await getDoc(doc(db, "usuarios", u.uid)); if (docSnap.exists()) { setFavorites(docSnap.data().favorites || []); setWatched(docSnap.data().watched || []); } } else { setUser(null); setProfile(null); } setAuthLoading(false); }); }, []); useEffect(() => { if (user && profile) { setIsFetching(true); fetch(CONTENT_API) .then(r => r.json()) .then(data => { const sorted = data.sort((a: any, b: any) => parseDate(b.DATA).getTime() - parseDate(a.DATA).getTime()); setContent(sorted); }) .finally(() => setIsFetching(false)); } }, [user, profile]); const toggleFavorite = async (link: string) => { if (!user) return; const userRef = doc(db, "usuarios", user.uid); if (favorites.includes(link)) { await updateDoc(userRef, { favorites: arrayRemove(link) }); setFavorites(f => f.filter(i => i !== link)); } else { await updateDoc(userRef, { favorites: arrayUnion(link) }); setFavorites(f => [...f, link]); } }; const toggleWatched = async (link: string) => { if (!user) return; const userRef = doc(db, "usuarios", user.uid); if (watched.includes(link)) { await updateDoc(userRef, { watched: arrayRemove(link) }); setWatched(w => w.filter(i => i !== link)); } else { await updateDoc(userRef, { watched: arrayUnion(link) }); setWatched(w => [...w, link]); } }; const yearsList = useMemo(() => { const years = content.map(i => String(i.ANOS || '')).filter(Boolean); return Array.from(new Set(years)).sort((a, b) => b.localeCompare(a)); }, [content]); const filteredContent = useMemo(() => { let result = content; if (searchTerm) { const q = searchTerm.toLowerCase(); result = result.filter(i => i.TITULO.toLowerCase().includes(q) || i.DESCRIÇÃO?.toLowerCase().includes(q)); } if (activeTab === 'fav') result = result.filter(i => favorites.includes(i.LINK)); if (activeTab === 'watched') result = result.filter(i => watched.includes(i.LINK)); if (activeTab === 'not-watched') result = result.filter(i => !watched.includes(i.LINK)); if (filterMember) result = result.filter(i => i.MEMBROS?.toLowerCase().includes(filterMember.toLowerCase())); if (filterYear) result = result.filter(i => String(i.ANOS) === filterYear); if (filterCat) result = result.filter(i => i.CATEGORIAS?.toLowerCase().includes(filterCat.toLowerCase())); return result; }, [content, searchTerm, activeTab, favorites, watched, filterMember, filterYear, filterCat]); const heroItems = useMemo(() => content.slice(0, 5), [content]); const resetFilters = () => { setFilterMember(''); setFilterYear(''); setFilterCat(''); setSearchTerm(''); }; if (authLoading) return
; if (!user) { return (
{ e.preventDefault(); try { await setPersistence(auth, browserLocalPersistence); await signInWithEmailAndPassword(auth, e.target.email.value, e.target.password.value); } catch (err: any) { alert("Erro de login. Verifique seus dados."); } }} className="space-y-6">

Não tem conta? Assinar ARMY TV+

); } if (!profile) { return (

Quem está assistindo?

{Object.entries(AVATARS).map(([id, url]) => (
{ localStorage.setItem('selectedProfile', id); setProfile(id); }} className="text-center group cursor-pointer">

{id}

))}
); } return (
{activeTab === 'home' && !searchTerm && !filterMember && !filterYear && !filterCat && ( )}
{activeTab !== 'home' && (

{activeTab === 'fav' ? 'Seus Favoritos' : activeTab === 'watched' ? 'Seus Assistidos' : 'Ainda não assistidos'}

)}
{isFetching ? (
) : filteredContent.length > 0 ? ( CATEGORIES_CONFIG.map(cat => ( i.CATEGORIAS?.toLowerCase().includes(cat.id.toLowerCase()))} onOpen={setSelectedItem} onToggleFavorite={toggleFavorite} onToggleWatched={toggleWatched} favorites={favorites} watched={watched} /> )) ) : (
Nenhum conteúdo encontrado.
)}
{selectedItem && (
{/* Botão de Fechar fixo para Mobile e Absoluto para Desktop */}

{selectedItem.TITULO}

98% Relevante 10+ {selectedItem.ANOS}

{selectedItem.DESCRIÇÃO || 'Conteúdo exclusivo do BTS! Explore os bastidores, shows e momentos inesquecíveis. 💜'}

Membros {selectedItem.MEMBROS || 'Todos os membros'}
Categoria {selectedItem.CATEGORIAS}
Lançamento {selectedItem.DATA}
)}
); } const rootElement = document.getElementById('root'); if (rootElement) { createRoot(rootElement).render(); }