import React, { useState } from 'react' const COLLAPSE_AT = 560 function stripTags(value) { return String(value || '') .replace(/<\/?(?:html|head|body|title|meta|link|script|style)[^>]*>/gi, '') .replace(/<[^>]*>/g, '') .trim() } function sanitizeDescriptionHtml(value) { const html = String(value || '').trim() if (!html) { return '' } if (/<\/?(?:html|head|body|title|meta|link|script|style)\b/i.test(html)) { return '' } return html } export default function ArtworkDescription({ artwork }) { const [expanded, setExpanded] = useState(false) const content = (artwork?.description || '').trim() const contentHtml = sanitizeDescriptionHtml(artwork?.description_html || '') const collapsed = content.length > COLLAPSE_AT && !expanded const fallbackText = contentHtml ? stripTags(contentHtml) : content if (content.length === 0) return null return (