import React, { useState } from 'react'; import { Package } from 'lucide-react'; import { usePluginBrandIcon } from '../../application/state/usePluginBrandIcon'; import { PluginContributionIcon } from './PluginContributionIcon'; import { resolveCatalogBrandIcon } from './catalogBrandIcons'; export function PluginBrandIcon({ plugin, entry, size = 32, className = '' }: { plugin?: NetcattyInstalledPlugin; entry?: NetcattyPluginCatalogEntry; size?: number; className?: string; }) { const manifest = plugin?.manifest ?? entry?.manifest; const icon = manifest?.icon; const key = JSON.stringify([plugin?.id, plugin?.activeVersion, plugin?.archiveSha256, plugin?.runtime?.quarantinedAt, icon]); const loaded = usePluginBrandIcon(plugin); const [failed, setFailed] = useState(null); const raster = plugin ? loaded : entry ? resolveCatalogBrandIcon(entry) : null; const imageKey = JSON.stringify([key, raster]); if (icon?.kind === 'theme') return ; if (!raster || failed === imageKey) return