/**
 * PageSerializer — M02 stays out of L9 plugin host (M17 decyzja 1).
 * Lives outside `EntitySerializer` registry; provides parallel
 * snapshot/restore/diff for markdown pages.
 *
 * Snapshot shape — `PageSnapshotData` per `db-m17-snapshots.md` (`dbm17shp01`).
 * Diff variant C (M17 decyzja 10): section-level operations + mandatory
 * `line_diff` inside each `section_modified` + `frontmatter_diff` /
 * `xml_refs_diff` side-channels.
 */
import type { PagesService } from './pages.js';
export declare const PAGE_SERIALIZER_VERSION = "1.1.0";
export interface PageXmlRef {
    tagType: string;
    attributes: Record<string, string>;
    position: number;
}
export interface PageSnapshotData {
    path: string;
    content: string;
    frontmatter: Record<string, unknown>;
    anchors: string[];
    xml_refs: PageXmlRef[];
}
export interface PageSection {
    anchor: string;
    heading: string;
    level: number;
    content: string;
    position: number;
}
export interface FrontmatterDiff {
    added: Record<string, unknown>;
    removed: Record<string, unknown>;
    changed: Array<{
        key: string;
        from: unknown;
        to: unknown;
    }>;
}
export interface XmlRefsDiff {
    added: PageXmlRef[];
    removed: PageXmlRef[];
}
/** Per-line diff inside a modified section (M17 decyzja 10 wariant C). */
export interface LineDiffLine {
    op: 'keep' | 'added' | 'removed';
    content: string;
}
export interface LineDiff {
    lines: LineDiffLine[];
}
export interface ModifiedSection {
    anchor: string;
    heading: string;
    level: number;
    /** Mandatory in variant C — line-level diff of section body. */
    line_diff: LineDiff;
}
export interface PageDiff {
    path: string;
    op: 'created' | 'deleted' | 'modified' | 'noop';
    added_sections: PageSection[];
    removed_sections: PageSection[];
    modified_sections: ModifiedSection[];
    moved_sections: Array<{
        anchor: string;
        from_position: number;
        to_position: number;
    }>;
    frontmatter_diff: FrontmatterDiff | null;
    xml_refs_diff: XmlRefsDiff | null;
}
/**
 * Compute line-level diff between two strings using Myers algorithm
 * (via `diff` npm). Returns a flat list of keep/added/removed lines
 * preserving order. Trailing newlines are normalized so identical
 * content with/without final \n compares equal.
 */
export declare function computeLineDiff(a: string, b: string): LineDiff;
/** Extract anchors in document order. */
export declare function extractAnchorsInOrder(content: string): string[];
export declare class PageSerializer {
    private pages;
    readonly version = "1.1.0";
    constructor(pages: PagesService);
    /**
     * Read the file from disk and produce a deterministic, byte-faithful
     * snapshot. Reads `content` byte-for-byte (preserves BOM, line endings).
     */
    snapshot(relPath: string): Promise<PageSnapshotData>;
    /** Build snapshot from already-read content (used for delete tombstones). */
    snapshotFromContent(relPath: string, content: string): PageSnapshotData;
    /**
     * Section-level diff (variant C in M17 decyzja 10). Sections keyed by
     * 8-char anchor (`<!-- anchor: ... -->`). Reorder without content change
     * → moved_section. Heading edited → counted as modified (heading is part
     * of section content in our parser). Each `modified` section carries a
     * mandatory `line_diff` computed via Myers diff over section bodies.
     */
    diff(a: PageSnapshotData | null, b: PageSnapshotData | null, relPath: string): PageDiff;
}
/**
 * Split markdown content into sections keyed by 8-char anchor. A section spans
 * from a heading (with anchor comment) to the next heading of equal or higher
 * level. Content without an anchor is grouped under an implicit root section
 * keyed by `__root__`.
 */
export declare function parseSections(content: string): PageSection[];
