/**
 * Utilities for splitting a PreTeXt article into individual sections and
 * merging them back into a complete document.
 *
 * Splitting always works at the `<section>`, `<introduction>`, and
 * `<conclusion>` level inside a top-level `<article>` element.
 */
import type { DocumentSection, DocumentSplitResult, DocumentSectionType } from "./types/sections";
export declare function splitDocument(xml: string): DocumentSplitResult;
/**
 * Reconstruct a complete PreTeXt document from a wrapper and an ordered
 * list of sections.
 *
 * The `wrapper` must be the value returned by a prior call to
 * {@link splitDocument}.
 */
export declare function mergeDocument(wrapper: string, sections: DocumentSection[]): string;
/**
 * Replace (or insert) the `<title>` of a section XML string with `newTitle`.
 * Returns the updated XML string.
 */
export declare function updateSectionTitle(sectionXml: string, newTitle: string): string;
/** Create a new blank `<section>` as a `DocumentSection`. */
export declare function createNewSection(title?: string): DocumentSection;
/** Create a blank `<introduction>` section. */
export declare function createIntroduction(): DocumentSection;
/** Create a blank `<conclusion>` section. */
export declare function createConclusion(): DocumentSection;
/**
 * Strip the outer wrapper element from a section XML string, returning just the
 * inner XML content (i.e. everything between `<section>` and `</section>`).
 * Used to show only the section body in the code editor so users can't
 * accidentally edit or delete the enclosing element.
 */
export declare function stripSectionWrapper(sectionXml: string): string;
/**
 * Re-wrap inner XML content (as returned by the code editor) with the correct
 * outer element for the given section type.
 *
 * Because `DocumentSectionType` values are identical to the XML tag names,
 * this is simply `<${type}>inner</${type}>`.
 */
export declare function rewrapSection(innerXml: string, type: DocumentSectionType): string;
/**
 * Ensure the given XML string has the correct outer element for its section
 * type.  If the outer tag is already present it is returned unchanged;
 * otherwise the content is re-wrapped so that accidental deletions in the
 * code editor are recovered gracefully.
 */
export declare function ensureSectionWrapper(content: string, type: DocumentSectionType): string;
/**
 * Split a LaTeX document into its top-level sections.
 *
 * Supports two splitting styles:
 * - `\section{…}` / `\section*{…}` command style (default)
 * - `\begin{section}…\end{section}` environment style
 *
 * Content before the first section marker becomes an `introduction` section.
 * The document preamble (everything up to and including `\begin{document}`)
 * is stored in the returned `wrapper` and must be passed back to
 * {@link mergeLatexDocument} to reconstruct the full document.
 */
export declare function splitLatexDocument(latex: string): DocumentSplitResult;
/**
 * Reconstruct a complete LaTeX document from a wrapper and an ordered list
 * of sections.
 */
export declare function mergeLatexDocument(wrapper: string, sections: DocumentSection[]): string;
/**
 * Strip the section-level header from a LaTeX section string so the code
 * editor shows only the body content.
 *
 * - For `\section{…}`-style sections: removes the leading `\section{…}` command.
 * - For `\begin{section}…\end{section}`-style: removes the wrapper tags.
 * - For introduction / conclusion (no header): returns as-is.
 */
export declare function stripLatexSectionWrapper(content: string, type: DocumentSectionType): string;
/**
 * Re-wrap inner LaTeX content (as produced by the code editor) with the
 * correct section header for the given section type and title.
 *
 * - `section` type: prepends `\section{title}`.
 * - `introduction` / `conclusion`: returns inner content unchanged.
 *
 * Pass `originalContent` to detect whether the document uses environment style
 * (`\begin{section}…\end{section}`) so the same style is preserved.
 */
export declare function rewrapLatexSection(inner: string, type: DocumentSectionType, title: string, originalContent?: string): string;
/**
 * Ensure the given LaTeX string has the correct section header/wrapper for its
 * type.  If the header is already present it is returned unchanged; otherwise
 * it is re-wrapped using `rewrapLatexSection` so that accidental deletions in
 * the code editor are recovered gracefully.
 */
export declare function ensureLatexSectionWrapper(content: string, type: DocumentSectionType, title: string, originalContent?: string): string;
/**
 * Replace (or insert) the section title in a LaTeX section string.
 *
 * - For `\section{…}` style: updates the command argument.
 * - For `\begin{section}` style: updates the `\title{…}` inside.
 */
export declare function updateLatexSectionTitle(content: string, newTitle: string): string;
/** Create a new blank LaTeX section as a `DocumentSection`. */
export declare function createNewLatexSection(title?: string): DocumentSection;
/** Create a blank LaTeX introduction (bare content before first `\section`). */
export declare function createLatexIntroduction(): DocumentSection;
/** Create a blank LaTeX conclusion (bare content after last `\section`). */
export declare function createLatexConclusion(): DocumentSection;
/**
 * Wrap all body content of a PreTeXt document (i.e. everything that is not
 * `<title>` or `<docinfo>`) into a single new `<section>`.
 *
 * Use this when a document has no sections and the user wants to start using
 * section-by-section editing mode.  The returned `wrapper` and `sections` can
 * be passed directly to {@link mergeDocument} to reconstruct the document.
 */
export declare function wrapDocumentAsSection(xml: string, sectionTitle?: string): DocumentSplitResult;
/**
 * Wrap all body content of a LaTeX document (everything between
 * `\begin{document}` and `\end{document}`, or the entire string if there is
 * no `\begin{document}`) into a single `\section{title}`.
 *
 * Use this when a document has no sections and the user wants to start using
 * section-by-section editing mode.
 */
export declare function wrapLatexDocumentAsSection(latex: string, sectionTitle?: string): DocumentSplitResult;
/**
 * Merge two adjacent sections into one, keeping the title of the first.
 *
 * - For PreTeXt: parses both sections and concatenates the body children
 *   (skipping the second section's `<title>`).
 * - For LaTeX: strips the second section's header and appends its body.
 *
 * @param a First (absorbing) section.
 * @param b Second section whose content is appended to `a`.
 * @param isLatex Whether the document source is LaTeX.
 */
export declare function mergeTwoSections(a: DocumentSection, b: DocumentSection, isLatex: boolean): DocumentSection;
/**
 * Extract `xml:id` and `label` attributes from the root element of a section
 * content string.  Returns empty strings when the attributes are absent.
 */
export declare function getSectionAttributes(content: string): {
    xmlId: string;
    label: string;
};
/**
 * Update the title, tag name (type), `xml:id`, and `label` of a section.
 *
 * Pass `null` for `xmlId` or `label` to remove the attribute entirely.
 * Omit a key (or pass `undefined`) to leave it unchanged.
 *
 * Returns a new `DocumentSection` with updated `content`, `title`, and `type`.
 */
export declare function updateSectionMetadata(section: DocumentSection, changes: {
    title?: string;
    type?: DocumentSectionType;
    xmlId?: string | null;
    label?: string | null;
}): DocumentSection;
/**
 * Wrap a single section into a complete, valid PreTeXt document suitable for
 * an isolated preview build.
 *
 * The result is a full `<pretext>` document containing:
 * - the supplied `<docinfo>` (if any)
 * - an `<article>` element with the optional `title` and the section content
 *
 * Passing this to `onPreviewRebuild` instead of the full merged document
 * dramatically reduces build times when only one section has changed.
 *
 * @param section - The section to preview.
 * @param docinfo - Optional raw `<docinfo>…</docinfo>` XML string.
 * @param title   - Optional document title shown in the build output.
 */
export declare function wrapSectionAsDocument(section: DocumentSection, docinfo?: string, title?: string): string;
/**
 * Wrap a single LaTeX section into a complete, buildable LaTeX document.
 *
 * Reconstructs `preamble + section.content + closing` using the opaque
 * `wrapper` string produced by {@link splitLatexDocument}.  Suitable for
 * passing to `onPreviewRebuild` when in sectioned LaTeX mode.
 *
 * @param section - The section to preview.
 * @param wrapper - The opaque wrapper returned by {@link splitLatexDocument}.
 */
export declare function wrapLatexSectionAsDocument(section: DocumentSection, wrapper: string): string;
