'use client' import { useState } from 'react' import { contentPieceBoardBucket, contentPieceMediaKind, interleaveCatalogItems, isCardCatalogItem, type CardCatalogItem, type ContentCatalogItem, type ContentPiecePublicItem, } from '@/lib/contentPieceCatalog' import { ContentCatalogCardItem } from './ContentCatalogCardItem' import { ContentPieceCard } from './ContentPieceCard' import { ContentPieceShareSheet } from './ContentPieceShareSheet' /** * S27 — the catalogue board (artefato: cena 01): the vertical board (video and * the S38 models) runs four columns from `lg`, audio/link keep a wide two-column * grid (no framing to preserve) and photo/text keep the compact scan row. One * piece plays at a time (switching unmounts the previous element) and the share * sheet is owned here, so every card opens the same vote message. * * S38 — the six card models are items of the same board: they take the vertical * board bucket and the whole item is one link to the studio (`/cards?model=`); * the old single invite tile is gone and no section groups them. */ export const ContentPieceCatalog = ({ items, themeMode, }: { items: readonly ContentCatalogItem[] /** S28 — the board is in the theme mode: the pieces state their provenance. */ themeMode: boolean }) => { const [playingId, setPlayingId] = useState(null) const [sharingItem, setSharingItem] = useState(null) const videoPieces: ContentPiecePublicItem[] = [] const widePieces: ContentPiecePublicItem[] = [] const compactItems: ContentPiecePublicItem[] = [] const cards: CardCatalogItem[] = [] for (const item of items) { if (isCardCatalogItem(item)) { cards.push(item) continue } const bucket = contentPieceBoardBucket(contentPieceMediaKind(item)) if (bucket === 'vertical') videoPieces.push(item) else if (bucket === 'wide') widePieces.push(item) else compactItems.push(item) } // S38 — the models alternate with the video pieces (never a block of their // own); the wide and compact rows keep the S27 board below. const verticalItems = interleaveCatalogItems(videoPieces, cards) const cardProps = (item: ContentPiecePublicItem) => ({ item, playing: playingId === item.id, onToggle: () => setPlayingId((current) => (current === item.id ? null : item.id)), onEnded: () => setPlayingId((current) => (current === item.id ? null : current)), onShare: setSharingItem, themeMode, }) return ( <> {verticalItems.length > 0 ? (
{verticalItems.map((item) => isCardCatalogItem(item) ? ( ) : ( ), )}
) : null} {widePieces.length > 0 ? (
{widePieces.map((item) => ( ))}
) : null} {compactItems.length > 0 ? (
{compactItems.map((item) => ( ))}
) : null} {sharingItem ? ( setSharingItem(null)} /> ) : null} ) }