import { MDXLDDocument } from 'mdxld';
export { MDXLDDocument } from 'mdxld';

/**
 * @mdxdb/fumadocs - Fumadocs content source adapter for mdxdb
 *
 * Provides integration between mdxdb document stores and Fumadocs,
 * allowing you to use mdxdb as a content source for Fumadocs documentation sites.
 *
 * @packageDocumentation
 */

/**
 * Virtual file types for Fumadocs source
 */
interface VirtualFile {
    path: string;
    type: 'page' | 'meta';
    data: Record<string, unknown>;
    slugs?: string[];
}
interface VirtualPage extends VirtualFile {
    type: 'page';
    data: PageData;
}
interface VirtualMeta extends VirtualFile {
    type: 'meta';
    data: MetaData;
}
/**
 * Page data structure for Fumadocs
 */
interface PageData {
    /** Page title */
    title: string;
    /** Page description */
    description?: string;
    /** Icon identifier */
    icon?: string;
    /** Full MDX/markdown content */
    content: string;
    /** Original mdxld document */
    doc: MDXLDDocument;
    /** Last modified date */
    lastModified?: Date;
    /** Additional frontmatter data */
    [key: string]: unknown;
}
/**
 * Meta data structure for folder configuration
 */
interface MetaData {
    /** Folder title */
    title?: string;
    /** Icon identifier */
    icon?: string;
    /** Whether this is a root folder */
    root?: boolean;
    /** Ordered list of page slugs */
    pages?: string[];
    /** Whether folder is expanded by default */
    defaultOpen?: boolean;
    /** Folder description */
    description?: string;
    /** Allow additional properties */
    [key: string]: unknown;
}
/**
 * Source configuration
 */
interface FumadocsSourceConfig {
    pageData: PageData;
    metaData: MetaData;
}
/**
 * Fumadocs-compatible source object
 */
interface FumadocsSource {
    files: VirtualFile[];
}
/**
 * Options for creating a Fumadocs source from mdxdb
 */
interface CreateSourceOptions {
    /**
     * Base path for content (e.g., 'docs' for /docs/*)
     * @default ''
     */
    basePath?: string;
    /**
     * Transform document data before adding to source
     */
    transform?: (doc: MDXLDDocument, path: string) => PageData;
    /**
     * Filter documents to include
     */
    filter?: (doc: MDXLDDocument, path: string) => boolean;
    /**
     * Custom slug generation from path
     */
    slugs?: (path: string) => string[];
    /**
     * Meta files configuration for folder ordering
     */
    meta?: Record<string, MetaData>;
}
/**
 * Create a Fumadocs source from an array of mdxld documents
 *
 * @param documents - Array of [path, document] tuples
 * @param options - Source configuration options
 * @returns Fumadocs-compatible source object
 *
 * @example
 * ```ts
 * import { createSource } from '@mdxdb/fumadocs'
 * import { loader } from 'fumadocs-core/source'
 *
 * const documents = [
 *   ['/docs/getting-started.mdx', doc1],
 *   ['/docs/api/reference.mdx', doc2],
 * ]
 *
 * const mdxdbSource = createSource(documents, {
 *   basePath: 'docs',
 * })
 *
 * export const source = loader({
 *   source: mdxdbSource,
 *   baseUrl: '/docs',
 * })
 * ```
 */
declare function createSource(documents: Array<[string, MDXLDDocument]>, options?: CreateSourceOptions): FumadocsSource;
/**
 * Options for the dynamic source adapter
 */
interface DynamicSourceOptions extends CreateSourceOptions {
    /**
     * Function to fetch documents dynamically
     */
    fetchDocuments: () => Promise<Array<[string, MDXLDDocument]>>;
    /**
     * Cache TTL in milliseconds
     * @default 60000 (1 minute)
     */
    cacheTTL?: number;
}
/**
 * Create a dynamic Fumadocs source that fetches content on demand
 *
 * Useful for remote content sources or when you need to refresh content
 * without rebuilding the entire site.
 *
 * @param options - Dynamic source options
 * @returns Object with methods to get source and refresh cache
 *
 * @example
 * ```ts
 * import { createDynamicSource } from '@mdxdb/fumadocs'
 *
 * const dynamicSource = createDynamicSource({
 *   fetchDocuments: async () => {
 *     const response = await fetch('/api/docs')
 *     return response.json()
 *   },
 *   cacheTTL: 60000,
 * })
 *
 * // Get cached or fresh source
 * const source = await dynamicSource.getSource()
 *
 * // Force refresh
 * await dynamicSource.refresh()
 * ```
 */
declare function createDynamicSource(options: DynamicSourceOptions): {
    /**
     * Get the source, using cache if valid
     */
    getSource(): Promise<FumadocsSource>;
    /**
     * Force refresh the cache
     */
    refresh(): Promise<FumadocsSource>;
    /**
     * Clear the cache
     */
    clearCache(): void;
};
/**
 * Helper to convert mdxdb query results to Fumadocs source
 *
 * @example
 * ```ts
 * import { queryToSource } from '@mdxdb/fumadocs'
 * import { db } from '@mdxdb/fs'
 *
 * const docs = await db.query({ type: 'Documentation' })
 * const source = queryToSource(docs, { basePath: 'docs' })
 * ```
 */
declare function queryToSource(documents: MDXLDDocument[], options?: CreateSourceOptions): FumadocsSource;
/**
 * Type guard to check if a virtual file is a page
 */
declare function isPage(file: VirtualFile): file is VirtualPage;
/**
 * Type guard to check if a virtual file is meta
 */
declare function isMeta(file: VirtualFile): file is VirtualMeta;

export { type CreateSourceOptions, type DynamicSourceOptions, type FumadocsSource, type FumadocsSourceConfig, type MetaData, type PageData, type VirtualFile, type VirtualMeta, type VirtualPage, createDynamicSource, createSource, isMeta, isPage, queryToSource };
