import { R as RiverbankClient, S as SiteResponse } from './types-BvcJU7zk.js';
import * as react_jsx_runtime from 'react/jsx-runtime';
import * as React$1 from 'react';
import React__default from 'react';
import { P as PageOutline, S as SdkCustomBlock } from './schema-Z6-afHJG.js';
import { T as TransformRegistry, a as ThemeTokens, R as RouteMap } from './core-DsNWrl3o.js';
import { T as Theme } from './types-CVykEqXN.js';
import { R as ResolvedBlockData, D as DataLoaderOverrides } from './types-DuQCNVV0.js';

type ViewModel = Record<string, unknown>;
type ComponentRegistry = Record<string, React__default.ComponentType<any>>;
type ResolverContext = {
    viewModel: ViewModel;
    registry: ComponentRegistry;
    transforms?: TransformRegistry;
    theme?: ThemeTokens;
    routes?: RouteMap;
    pathBase?: string;
    blockId?: string | null;
    blockKind?: string;
    blockContent?: unknown;
    blockBindings?: Record<string, unknown>;
    fragmentRegistry?: Record<string, any>;
};

/**
 * Occurrence context for event pages.
 * Passed through to blocks that need occurrence information (e.g., event-registration).
 */
type OccurrenceContextData = {
    id: string;
    seriesId: string;
    startsAt: string;
    endsAt: string;
    capacityOverride?: number | null;
    overrides?: Record<string, unknown> | null;
};
type PageRendererDataContext = {
    siteId?: string;
    pageId?: string;
    resolvedData?: Record<string, Record<string, unknown>>;
    previewStage?: 'published' | 'preview';
    routes?: RouteMap;
    occurrenceContext?: OccurrenceContextData | null;
    contentEntry?: Record<string, unknown> | null;
    supabaseUrl?: string;
};
/**
 * Props passed to block override components.
 *
 * These props are RSC-safe (no functions) so overrides can be Client Components.
 * Unlike internal SDK block components, overrides don't receive `registry` or
 * `fragmentRegistry` which contain function references that can't cross the
 * RSC serialization boundary.
 *
 * @example
 * ```tsx
 * 'use client';
 *
 * import type { BlockOverrideProps, HeroContent } from '@riverbankcms/sdk/rendering';
 *
 * export function CustomHero({ content, theme, data }: BlockOverrideProps<HeroContent>) {
 *   const [expanded, setExpanded] = useState(false);
 *   return <div>...</div>;
 * }
 * ```
 */
type BlockOverrideProps<TContent = Record<string, unknown>> = {
    /** Block content data */
    content: TContent;
    /** Theme tokens for styling */
    theme?: ThemeTokens;
    /** Full theme configuration */
    themeConfig?: Theme;
    /** Pre-fetched data from data loaders */
    data?: Record<string, unknown>;
    /** Block instance ID (null for unsaved blocks) */
    blockId: string | null;
    /** Block kind identifier (e.g., "block.hero" or "custom.my-block") */
    blockKind: string;
};
/**
 * Block override component type.
 *
 * Override components can be either Server Components or Client Components.
 * They receive only serializable props (no functions) to support RSC boundaries.
 *
 * @example Server Component override
 * ```tsx
 * export function CustomHero({ content, theme, data }: BlockOverrideProps<HeroContent>) {
 *   return <div className="custom-hero">...</div>;
 * }
 * ```
 *
 * @example Client Component override
 * ```tsx
 * 'use client';
 *
 * export function CustomHero({ content, theme, data }: BlockOverrideProps<HeroContent>) {
 *   const [state, setState] = useState(null);
 *   return <div className="custom-hero">...</div>;
 * }
 * ```
 */
type BlockOverrideComponent = React$1.ComponentType<BlockOverrideProps<any>>;
/**
 * Map of block kinds to custom override components.
 * Keys can be either:
 * - Full block kind: "block.hero"
 * - Short form: "hero" (will match "block.hero")
 *
 * @example
 * ```tsx
 * const overrides: BlockOverrides = {
 *   'hero': CustomHero,        // CustomHero uses BlockOverrideProps<HeroContent>
 *   'bodyText': CustomBodyText, // CustomBodyText uses BlockOverrideProps<BodyTextContent>
 * };
 * ```
 */
type BlockOverrides = Record<string, BlockOverrideComponent>;
/**
 * SDK site configuration for custom block rendering.
 * Minimal type containing only what PageRenderer needs.
 */
type SdkConfigForRenderer = {
    customBlocks?: SdkCustomBlock[];
};
interface PageRendererProps {
    theme: Theme;
    page: PageOutline | null;
    usePlaceholders?: boolean;
    dataContext?: PageRendererDataContext;
    routeMap?: RouteMap;
    wrapBlock?: (blockId: string, rendered: React$1.ReactNode) => React$1.ReactNode;
    registry?: ResolverContext["registry"];
    themeTokens?: ThemeTokens;
    blockOverrides?: BlockOverrides;
    sdkConfig?: SdkConfigForRenderer | null;
}
declare function PageRenderer({ theme, page, usePlaceholders, dataContext, wrapBlock, registry, themeTokens: providedThemeTokens, routeMap, blockOverrides, sdkConfig, }: PageRendererProps): react_jsx_runtime.JSX.Element;

type PageProps = {
    page: PageOutline;
    theme: Theme;
    siteId: string;
    themeTokens?: ThemeTokens;
    resolvedData?: ResolvedBlockData;
    routeMap?: RouteMap;
    /**
     * SDK site configuration containing theme palette overrides.
     * When provided, the SDK palette tokens are merged into the theme tokens,
     * allowing blocks to use SDK-defined color tokens for section backgrounds.
     */
    sdkConfig?: RuntimeSdkConfig | null;
    /**
     * Supabase storage URL for direct image access.
     * SDK sites receive this from the API instead of requiring NEXT_PUBLIC_SUPABASE_URL env var.
     */
    supabaseUrl?: string;
    /**
     * Additional context data for content entry pages.
     * Used to pass occurrence context and content entry data to blocks.
     */
    dataContext?: {
        /** Occurrence context for event pages (from URL like /events/yoga/2025-01-15) */
        occurrenceContext?: OccurrenceContextData | null;
        /** Content entry data for template pages */
        contentEntry?: Record<string, unknown> | null;
    };
    wrapBlock?: (blockId: string, rendered: React.ReactNode) => React.ReactNode;
    registry?: Parameters<typeof PageRenderer>[0]['registry'];
    usePlaceholders?: boolean;
    /**
     * Custom components to override default block rendering.
     * Keys can be full block kind ("block.hero") or short form ("hero").
     *
     * This is SSR-safe - no context or hooks required.
     *
     * @example
     * ```tsx
     * <Page
     *   {...pageData}
     *   blockOverrides={{
     *     'hero': MyCustomHero,
     *     'block.testimonials': MyCustomTestimonials,
     *   }}
     * />
     * ```
     */
    blockOverrides?: BlockOverrides;
};
/**
 * Pure renderer for Riverbank CMS pages.
 *
 * This component expects all data to be provided via props.
 * For data fetching, use:
 * - Server-side: `await loadPage({ client, siteId, path })`
 * - Client-side: `usePage({ client, siteId, path })`
 *
 * @example Server-side (Next.js App Router)
 * ```tsx
 * import { createRiverbankClient } from '@riverbankcms/sdk';
 * import { loadPage, Page } from '@riverbankcms/sdk/rendering';
 *
 * const client = createRiverbankClient({ apiKey, baseUrl });
 *
 * export default async function PageRoute({ params }) {
 *   const pageData = await loadPage({
 *     client,
 *     siteId: 'site-id',
 *     path: `/${params.slug}`,
 *   });
 *
 *   return <Page {...pageData} />;
 * }
 * ```
 *
 * @example Client-side
 * ```tsx
 * import { createRiverbankClient } from '@riverbankcms/sdk';
 * import { usePage, Page } from '@riverbankcms/sdk/rendering';
 *
 * const client = createRiverbankClient({ apiKey, baseUrl });
 *
 * function MyPage({ path }) {
 *   const pageData = usePage({ client, siteId: 'site-id', path });
 *
 *   if (pageData.loading) return <LoadingState />;
 *   if (pageData.error) return <ErrorState error={pageData.error} />;
 *   if (!pageData.page) return <NotFound />;
 *
 *   return <Page {...pageData} />;
 * }
 * ```
 */
declare function Page({ page, theme, themeTokens: providedTokens, siteId, resolvedData, routeMap, wrapBlock, registry, usePlaceholders, blockOverrides, sdkConfig, supabaseUrl, dataContext, }: PageProps): react_jsx_runtime.JSX.Element;

/**
 * Server-side helper to fetch all data needed for <Page> component.
 *
 * Use this in server components, getServerSideProps, or API routes.
 */

/**
 * SDK config from API response (without siteId which is stripped at storage).
 * This is the runtime representation - for defining configs, use RiverbankSiteConfig.
 */
type RuntimeSdkConfig = NonNullable<SiteResponse['sdkConfig']>;
type LoadPageParams = {
    client: RiverbankClient;
    siteId: string;
    path: string;
    pageId?: string;
    /**
     * If true, fetches draft/unpublished content instead of published content.
     * This affects both the page structure and block data loaders.
     * Requires API key with site access.
     *
     * @default false
     */
    preview?: boolean;
    /**
     * Code-based data loaders for custom blocks.
     *
     * Use this to fetch data from external APIs (not just whitelisted CMS endpoints).
     * Keys are block kinds (e.g., 'custom.featured-products').
     *
     * Config-based loaders (defined in riverbank.config.ts) run first.
     * Code loaders run second and take precedence on key conflicts.
     *
     * @example
     * ```typescript
     * const pageData = await loadPage({
     *   client,
     *   siteId: 'site-123',
     *   path: '/',
     *   dataLoaderOverrides: {
     *     'custom.featured-products': {
     *       products: async (ctx) => {
     *         const res = await fetch(`https://api.shop.com/products?category=${ctx.content.categoryId}`);
     *         return res.json();
     *       },
     *     },
     *   },
     * });
     * ```
     */
    dataLoaderOverrides?: DataLoaderOverrides;
    /**
     * URL search parameters from the page request.
     * Passed to code-based data loaders for pagination, filtering, etc.
     *
     * @example
     * ```typescript
     * // In Next.js App Router
     * export default async function Page({ params, searchParams }) {
     *   const pageData = await loadPage({
     *     client,
     *     siteId: 'site-123',
     *     path: `/${params.slug || ''}`,
     *     searchParams: await searchParams,
     *   });
     *   return <Page {...pageData} />;
     * }
     * ```
     */
    searchParams?: Record<string, string | string[] | undefined>;
};
type LoadPageResult = Omit<PageProps, 'registry' | 'wrapBlock' | 'usePlaceholders' | 'blockOverrides'> & {
    /**
     * SDK site configuration, if available.
     * Contains SDK-defined theme palette, section backgrounds, and style options.
     */
    sdkConfig: RuntimeSdkConfig | null;
    /**
     * Supabase storage URL for direct image access.
     * SDK sites use this instead of NEXT_PUBLIC_SUPABASE_URL env var.
     */
    supabaseUrl?: string;
};
/**
 * Server-side helper to fetch all data needed for <Page> component.
 *
 * Fetches site data, page data, and prefetches block data loaders in parallel.
 *
 * @example Next.js App Router (published content)
 * ```tsx
 * import { createRiverbankClient } from '@riverbankcms/sdk';
 * import { loadPage, Page } from '@riverbankcms/sdk/rendering';
 *
 * const client = createRiverbankClient({
 *   apiKey: process.env.RIVERBANK_API_KEY!,
 *   baseUrl: process.env.NEXT_PUBLIC_DASHBOARD_URL + '/api',
 * });
 *
 * export default async function PageRoute({ params }) {
 *   const pageData = await loadPage({
 *     client,
 *     siteId: 'site-123',
 *     path: `/${params.slug || ''}`,
 *   });
 *
 *   return <Page {...pageData} />;
 * }
 * ```
 *
 * @example Next.js App Router (preview/draft content)
 * ```tsx
 * export default async function PreviewRoute({ params, searchParams }) {
 *   const pageData = await loadPage({
 *     client,
 *     siteId: searchParams.siteId,
 *     path: `/${params.slug || ''}`,
 *     preview: true, // Fetch draft content
 *   });
 *
 *   return <Page {...pageData} />;
 * }
 * ```
 *
 * @example Next.js Pages Router (getServerSideProps)
 * ```tsx
 * export async function getServerSideProps({ params }) {
 *   const pageData = await loadPage({
 *     client,
 *     siteId: 'site-123',
 *     path: `/${params.slug || ''}`,
 *   });
 *
 *   return { props: pageData };
 * }
 *
 * export default function PageRoute(props) {
 *   return <Page {...props} />;
 * }
 * ```
 */
declare function loadPage(params: LoadPageParams): Promise<LoadPageResult>;

export { type BlockOverrides as B, type LoadPageParams as L, type PageProps as P, type RuntimeSdkConfig as R, type LoadPageResult as a, Page as b, PageRenderer as c, type BlockOverrideComponent as d, type BlockOverrideProps as e, type ResolverContext as f, loadPage as l };
