import { jsx as _jsx } from "react/jsx-runtime"; /** A localized text field may arrive as a string or a { locale: value } map. */ function pickText(value, locale) { if (typeof value === 'string') { return value; } if (value && typeof value === 'object') { const map = value; const preferred = locale ? map[locale] : undefined; if (typeof preferred === 'string') { return preferred; } const first = Object.values(map).find((v)=>typeof v === 'string'); return first ?? null; } return null; } async function loadBranding(props, settingsSlug, nameField, imageField) { const { payload } = props; if (!payload) { return { name: null, url: null }; } try { const locale = typeof props.locale === 'string' ? props.locale : props.locale?.code; const settings = await payload.findGlobal({ slug: settingsSlug, depth: 1, ...locale ? { locale: locale } : {} }); const name = pickText(settings[nameField], locale); const image = settings[imageField]; const url = image && typeof image === 'object' && typeof image.url === 'string' ? image.url : null; return { name, url }; } catch (error) { console.warn('[ipal] admin branding: falling back to Payload default:', error); return { name: null, url: null }; } } /** * Admin panel logo — this is the LARGE logo on the login / unauthorized screens * (Payload uses `graphics.Icon` for the small nav glyph). SiteSettings `logo`, * falls back to `siteName` text. Sized generously for the login screen. */ export async function AdminLogo(props = {}) { const { imageField = 'logo', nameField = 'siteName', settingsSlug = 'site-settings' } = props; const { name, url } = await loadBranding(props, settingsSlug, nameField, imageField); if (url) { return /*#__PURE__*/ _jsx("img", { alt: name ?? '', src: url, style: { height: 'auto', maxHeight: 120, maxWidth: 420, width: 'auto' } }); } if (name) { return /*#__PURE__*/ _jsx("div", { style: { fontSize: '2rem', fontWeight: 600 }, children: name }); } return null // nothing configured → Payload's default ; } /** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */ export async function AdminIcon(props = {}) { const { imageField = 'favicon', nameField = 'siteName', settingsSlug = 'site-settings' } = props; const { name, url } = await loadBranding(props, settingsSlug, nameField, imageField); if (url) { return /*#__PURE__*/ _jsx("img", { alt: name ?? '', src: url, style: { height: 'auto', maxHeight: 28, maxWidth: 28, width: 'auto' } }); } if (name) { return /*#__PURE__*/ _jsx("div", { style: { fontWeight: 700 }, children: name.slice(0, 2).toUpperCase() }); } return null; } /** * Discreet vendor credit: "Technology supported by Intecion.com". This is the * PLUGIN VENDOR's credit (Intecion ships ipal-kit, the framework), not client * data — a sensible default here is fine and A0-safe. The client's own brand * still owns the logo/name; this is a small line stating who supports the tech. * Text/URL overridable; turn it off with `whiteLabel: { credit: false }`. * * Wired by ipalKit into admin.components.afterNavLinks (nav) AND afterLogin * (login screen footer). `variant` adjusts placement: * - 'nav' → left-aligned line under the nav links * - 'login' → centered line below the login form */ export function IntecionCredit(props = {}) { const { text = 'Technology supported by Intecion.com', url = 'https://intecion.com', variant = 'nav' } = props; const style = variant === 'login' ? { color: 'inherit', display: 'block', fontSize: '0.75rem', marginTop: '2rem', opacity: 0.6, padding: '0.5rem', textAlign: 'center', textDecoration: 'none' } : { color: 'inherit', display: 'block', fontSize: '0.75rem', opacity: 0.6, padding: '0.75rem 1rem', textDecoration: 'none' }; return /*#__PURE__*/ _jsx("a", { href: url, rel: "noopener noreferrer", style: style, target: "_blank", children: text }); } //# sourceMappingURL=adminGraphics.js.map