'use client';
import { jsx as _jsx } from "react/jsx-runtime";
/**
 * Pluggable canvas renderers for custom section types.
 *
 * By default the editor canvas renders custom (config-declared) and unmanaged
 * section types as structural placeholders. Projects that want a real design
 * preview inside the admin can pass renderers to `<AdminRoot
 * sectionRenderers={...}>`; the canvas and the eye preview then use them in
 * place of the placeholder.
 *
 * The renderer signature is a structural mirror of `SectionRenderer` from
 * `@actuate-media/sections-react` (cms-admin depends on cms-core only, so the
 * type is duplicated rather than imported). Because the shapes match, a
 * consumer can hand `AdminRoot` the exact same components it registers for
 * the public site:
 *
 * ```tsx
 * import { OPAL_RENDERERS } from './sections' // SectionRendererMap
 * <AdminRoot sectionRenderers={OPAL_RENDERERS} ... />
 * ```
 *
 * Renderers run inside the admin bundle, so they must be client-safe (no
 * server-only imports). Each one is wrapped in an error boundary — a throwing
 * renderer falls back to the structural placeholder instead of taking down
 * the editor.
 */
import { createContext, useContext } from 'react';
/**
 * Render options passed to every admin renderer. Rich text is sanitized on
 * write by cms-core, so the canvas (same trust domain as the public default)
 * uses the identity sanitizer; images render as plain lazy `<img>` since the
 * editor canvas has no next/image pipeline.
 */
export const ADMIN_RENDER_OPTIONS = {
    sanitizeHtml: (html) => html,
    baseUrl: '',
    renderImage: ({ src, alt, className, priority, width, height }) => (_jsx("img", { src: src, alt: alt, className: className, width: width ?? undefined, height: height ?? undefined, loading: priority ? undefined : 'lazy' })),
};
const AdminSectionRenderersContext = createContext({});
export const AdminSectionRenderersProvider = AdminSectionRenderersContext.Provider;
/** The renderer map passed to `<AdminRoot sectionRenderers>` (empty by default). */
export function useAdminSectionRenderers() {
    return useContext(AdminSectionRenderersContext);
}
//# sourceMappingURL=admin-renderers.js.map