/**
 * Page hierarchy resolution for the Pages tree view.
 *
 * Parent resolution strategy (in priority order):
 *   1. `parentPageId` — explicit link, used when it points at a page that
 *      exists in the set (and isn't the page itself).
 *   2. Path-prefix derivation — for rows without a usable `parentPageId`,
 *      the longest existing path prefix wins: "/about/team" becomes a child
 *      of the page whose path is "/about". Missing intermediate levels are
 *      skipped ("/a/b/c" with no "/a/b" attaches to "/a"). The root path
 *      "/" is never treated as a prefix parent, so top-level pages stay
 *      siblings of the homepage.
 *
 * Safety guarantees:
 *   - Orphans (parent id not in the set) become roots.
 *   - Cycles (a → b → a) are broken deterministically: walking up from each
 *     page in input order, the edge that closes a cycle is severed and that
 *     page becomes a root. Every page appears in the tree exactly once.
 *   - Sibling ordering is stable: title (locale-aware), then path.
 *
 * Pure functions — no network, no React — so the view and the unit tests
 * share one implementation.
 */
import type { Page } from './pages-service.js';
export interface PageTreeNode {
    page: Page;
    children: PageTreeNode[];
}
/** One visible row of the flattened tree table. */
export interface PageTreeRow {
    page: Page;
    depth: number;
    hasChildren: boolean;
}
/** Build the parent/child hierarchy for the tree view. Returns root nodes. */
export declare function buildPageTree(pages: Page[]): PageTreeNode[];
/**
 * Flatten the tree into visible rows: children render only when their
 * parent's id is in `expanded`.
 */
export declare function flattenPageTree(nodes: PageTreeNode[], expanded: Set<string>): PageTreeRow[];
/** Default expand state: every root node that has children starts open. */
export declare function defaultExpandedIds(roots: PageTreeNode[]): Set<string>;
/** Ids of every page in `id`'s subtree (excluding `id` itself). */
export declare function collectDescendantIds(roots: PageTreeNode[], id: string): Set<string>;
export type ReparentCheck = {
    ok: true;
} | {
    ok: false;
    reason: string;
};
/**
 * Validate a drag-reparent: `sourceId` becomes a child of `targetId`
 * (or a root when `targetId` is null). Rejects self-drops, drops into the
 * page's own subtree (would create a cycle), and no-op moves.
 */
export declare function checkReparent(roots: PageTreeNode[], sourceId: string, targetId: string | null): ReparentCheck;
//# sourceMappingURL=pages-tree.d.ts.map