/**
 * Shared page content resolution.
 *
 * This module provides a unified resolution function for both SDK and frontend.
 * It handles the complete routing flow: detection, content loading, and occurrence resolution.
 *
 * Both SDK and frontend inject their own auth/loaders, but share the same resolution logic.
 */
import type { ContentTypeRoutingInfo } from './contentTypeResolver';
import type { ResolveEntrySubrouteResponse } from '../client/types';
type ResolvedSubroute = NonNullable<ResolveEntrySubrouteResponse['subroute']>;
export type OccurrenceData = Extract<ResolvedSubroute, {
    kind: 'event-occurrence';
}>['occurrence'];
export type CourseRunData = Extract<ResolvedSubroute, {
    kind: 'course-run';
}>['run'];
export type EntrySubrouteData = {
    kind: 'event-occurrence';
    occurrence: OccurrenceData;
} | {
    kind: 'course-run';
    run: CourseRunData;
};
/**
 * Options for resolving page content.
 *
 * @template TContent - The content type (varies by caller)
 */
export interface ResolvePageContentOptions<TContent> {
    /** The URL path to resolve (e.g., '/events/yoga-class/2025-01-15') */
    path: string;
    /** Content type routing info for occurrence detection */
    contentTypes: ContentTypeRoutingInfo[];
    /**
     * Load content by path.
     *
     * **Contract:** MUST return null for not-found (not throw).
     * Callers should wrap their client to normalize exceptions.
     *
     * @param path - The path to load
     * @returns Content if found, null if not found
     */
    loadContent: (path: string) => Promise<TContent | null>;
    /**
     * Resolve occurrence by entry ID and segment.
     *
     * @param entryId - The parent entry's ID
     * @param segment - The occurrence segment (date or UUID)
     * @returns Occurrence data if valid, null if invalid
     */
    resolveEntrySubroute: (args: {
        entryId: string;
        kind?: string | null;
        entryTypeKey: string | null;
        segment: string;
    }) => Promise<EntrySubrouteData | null>;
    /**
     * Check if content is an entry (vs a page).
     * Used to determine if occurrence resolution is applicable.
     */
    isEntry: (content: TContent) => boolean;
    /**
     * Get the entry ID from content.
     * Only called when isEntry returns true.
     */
    getEntryId: (content: TContent) => string;
    /**
     * Get the entry type key (content type key/slug) from content.
     * Only called when isEntry returns true.
     */
    getEntryTypeKey: (content: TContent) => string | null;
    /**
     * Optional optimization hook: decide whether to attempt subroute resolution
     * based on the content type and segment, before loading the parent content.
     *
     * If omitted, subroute resolution is attempted whenever the URL matches an
     * occurrence pattern (event) or the fallback extractor (CMS-only types).
     */
    shouldAttemptEntrySubroute?: (args: {
        entryTypeKey: string | null;
        segment: string;
    }) => boolean;
}
/**
 * Result of page content resolution.
 */
export type PageResolutionResult<TContent> = {
    /** Content was found */
    found: true;
    /** The loaded content */
    content: TContent;
    /** Entry subroute data if this is a subroute URL, null otherwise */
    entrySubrouteData: EntrySubrouteData | null;
    /** The actual path that was loaded (parent path for occurrences) */
    resolvedPath: string;
} | {
    /** Content was not found */
    found: false;
    /** Reason for not finding content */
    reason: 'not-found' | 'invalid-subroute';
};
/**
 * Resolve page content for a given path.
 *
 * This function implements the shared routing logic for both SDK and frontend:
 *
 * 1. **Known subroute fast-path** - For paths that clearly match a known entry type route pattern,
 *    try parent+subroute resolution first (avoids a guaranteed exact-path miss).
 * 2. **Exact match** - Load content directly for the full path
 * 3. **Fallback** - Try subroute resolution even when the entry type isn't in `contentTypes`
 *
 * ## Error Handling
 *
 * The `loadContent` function MUST return `null` for not-found, not throw.
 * SDK callers should wrap their client to catch and normalize exceptions.
 *
 * @template TContent - The content type
 * @param options - Resolution options with injected loaders
 * @returns Resolution result indicating success or failure
 */
export declare function resolvePageContent<TContent>(options: ResolvePageContentOptions<TContent>): Promise<PageResolutionResult<TContent>>;
export {};
