import * as React from 'react';
import type { ContentLoadingVariant, HastRoot } from "./types.mjs";
/**
 * Render-time "collapse to empty" for the loading placeholder: demotes every
 * collapsed-visible frame type in a fallback `HastRoot` to its hidden variant
 * (matching `<Pre>`'s live rewrite) so the collapse CSS paints an empty window,
 * and records `focusedLines: 0`. Mutates the freshly-decoded root in place.
 */
export declare function applyCollapseToEmptyToFallbackHast(root: HastRoot): HastRoot;
/** A decoded extra-file fallback: the rendered `HastRoot` plus its line counts. */
export interface UseCodeFallbackFile {
  source: HastRoot;
  totalLines?: number;
  focusedLines?: number;
  collapsible?: boolean;
}
export interface UseCodeFallbackResult {
  source?: HastRoot;
  fileNames?: string[];
  extraSource?: Record<string, UseCodeFallbackFile>;
  extraVariants?: Record<string, UseCodeFallbackVariantResult>;
  /**
   * `true` when the surrounding `CodeHighlighter` uses `fallbackCollapsed`, so
   * `source` is only the collapsed window. A `ContentLoading` should disable any
   * expand control while this is set — the hidden lines arrive with the full
   * content, not the fallback.
   */
  collapsed?: boolean;
  /**
   * Line counts for the displayed file, threaded from the server (the compact
   * `source` has dropped `root.data`, where they live). A `ContentLoading` mirrors
   * them onto the fallback `<code>` as `data-total-lines` / `data-focused-lines` so
   * it matches the hydrated `<Pre>`. `focusedLines` is the visible-window size —
   * forced to 0 here when `collapseToEmpty` empties the painted window, so it stays
   * consistent with the demoted `source`. `collapsible` is threaded separately
   * from the enhancer/loader because counts alone cannot describe whether the
   * collapsed frame structure has hidden content to expand into.
   */
  totalLines?: number;
  focusedLines?: number;
  collapsible?: boolean;
  /**
   * Ready-to-render `<code>` for the displayed file — the rendered `source` with
   * `data-filename` / `data-collapsible` / `data-total-lines` / `data-focused-lines`
   * and the `language-{language}` class already applied, matching `<Pre>`. Drop it
   * into a `<pre>` so a `ContentLoading` needn't re-wire (or drift from) those
   * attributes. `null` when there's no source to paint.
   */
  code?: React.ReactNode;
}
export interface UseCodeFallbackVariantResult {
  fileNames?: string[];
  source?: HastRoot;
  totalLines?: number;
  focusedLines?: number;
  collapsible?: boolean;
  extraSource?: Record<string, UseCodeFallbackFile>;
}
interface UseCodeFallbackProps extends ContentLoadingVariant {
  initialVariant?: string;
  initialFilename?: string;
  extraVariants?: Record<string, ContentLoadingVariant>;
  fallbackCollapsed?: boolean;
  collapseToEmpty?: boolean;
  totalLines?: number;
  focusedLines?: number;
  collapsible?: boolean;
}
/**
 * Hook for `ContentLoading` components to hoist fallback data
 * to `CodeHighlighterClient` for text-dictionary derivation.
 *
 * On the server-rendered path, Code is stripped of `fallback` entries
 * and the data arrives on ContentLoading as `source`/`extraSource` props
 * in compact `FallbackNode[]` format. This hook converts them back to
 * `HastRoot` for rendering and hoists the compact form for dictionaries.
 *
 * On the client-loaded path, `useInitialData` already hoists directly,
 * so this hook simply passes props through.
 *
 * @example
 * ```tsx
 * function MyContentLoading(props: ContentLoadingProps<{}>) {
 *   const { source, extraSource } = useCodeFallback(props);
 *   return (
 *     <div>
 *       {source && hastToJsx(source)}
 *     </div>
 *   );
 * }
 * ```
 */
export declare function useCodeFallback(props?: UseCodeFallbackProps): UseCodeFallbackResult;
export {};