## API Report File for "@eigenpal/docx-editor-core"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

// @public
export function addRepeatingSectionItem(doc: Document_2, filter: ContentControlFilter, options?: {
    afterIndex?: number;
}): Document_2;

// @public
export type AgentCommand = InsertTextCommand | ReplaceTextCommand | DeleteTextCommand | FormatTextCommand | FormatParagraphCommand | ApplyStyleCommand | InsertTableCommand | InsertImageCommand | InsertHyperlinkCommand | RemoveHyperlinkCommand | InsertParagraphBreakCommand | MergeParagraphsCommand | SplitParagraphCommand | SetVariableCommand | ApplyVariablesCommand;

// @public
export interface AgentContext {
    availableStyles: StyleInfo[];
    characterCount: number;
    hasHyperlinks: boolean;
    hasImages: boolean;
    hasTables: boolean;
    language?: string;
    outline: ParagraphOutline[];
    paragraphCount: number;
    sections: SectionInfo[];
    variableCount: number;
    variables: string[];
    wordCount: number;
}

// @public
export interface AgentContextOptions {
    includeFormatting?: boolean;
    includeTableContent?: boolean;
    maxOutlineParagraphs?: number;
    outlineMaxChars?: number;
}

// @public
export interface AgentResponse {
    commands?: AgentCommand[];
    error?: string;
    metadata?: Record<string, unknown>;
    newContent?: AgentContent[];
    newText?: string;
    success: boolean;
    warnings?: string[];
}

// @public
export interface AgentSelectionContext {
    formatting: Partial<TextFormatting>;
    inHyperlink?: boolean;
    inTable?: boolean;
    paragraph: ParagraphContext;
    paragraphFormatting: Partial<ParagraphFormatting>;
    range: Range_2;
    selectedText: string;
    suggestedActions?: SuggestedAction[];
    textAfter: string;
    textBefore: string;
}

// @public
export type AIAction = 'askAI' | 'rewrite' | 'expand' | 'summarize' | 'translate' | 'explain' | 'fixGrammar' | 'makeFormal' | 'makeCasual' | 'custom';

// @public
export interface AIActionRequest {
    action: AIAction;
    context: AgentSelectionContext;
    customPrompt?: string;
    options?: Record<string, unknown>;
    targetLanguage?: string;
}

// @public
export interface ApplyStyleCommand extends BaseCommand {
    paragraphIndex: number;
    styleId: string;
    // (undocumented)
    type: 'applyStyle';
}

// @public
export interface ApplyVariablesCommand extends BaseCommand {
    // (undocumented)
    type: 'applyVariables';
    values: Record<string, string>;
}

// @public
export function buildExtendedSelectionContext(doc: Document_2, range: Range_2, options?: SelectionContextOptions): ExtendedSelectionContext;

// @public
export function buildSelectionContext(doc: Document_2, range: Range_2, options?: SelectionContextOptions): AgentSelectionContext;

// @public
export function buildSelectionContextFromContext(doc: Document_2, range: Range_2, options?: ContextSelectionOptions): AgentSelectionContext;

// @public
export function comparePositions(a: Position_2, b: Position_2): -1 | 0 | 1;

// @public
export class ContentControlBoundError extends Error {
    constructor();
}

// @public
export interface ContentControlFilter {
    alias?: string;
    id?: number;
    tag?: string;
    type?: SdtType;
}

// @public
export interface ContentControlInfo {
    alias?: string;
    checked?: boolean;
    dataBinding?: SdtDataBinding;
    dateFormat?: string;
    depth: number;
    id?: number;
    listItems?: {
        displayText: string;
        value: string;
    }[];
    lock?: SdtProperties['lock'];
    path: number[];
    placeholder?: string;
    sdtType: SdtType;
    showingPlaceholder?: boolean;
    tag?: string;
    text: string;
}

// @public
export class ContentControlLockedError extends Error {
    constructor(lock: SdtProperties['lock'], op: 'edit' | 'remove');
}

// @public
export class ContentControlNotFoundError extends Error {
    constructor(filter: ContentControlFilter);
}

// @public
export class ContentControlTypeError extends Error {
    constructor(sdtType: SdtType);
}

// @public
export type ContentControlValue = {
    kind: 'dropdown';
    value: string;
} | {
    kind: 'checkbox';
    checked: boolean;
} | {
    kind: 'date';
    date: string;
};

// @public
export class ContentControlValueError extends Error {
    constructor(message: string);
}

// @public
export interface ContextSelectionOptions {
    contextChars?: number;
    includeSuggestions?: boolean;
}

// @public
export function countCharacters(text: string, includeSpaces?: boolean): number;

// @public
export function countWords(text: string): number;

// @public
export function createAgent(buffer: ArrayBuffer): Promise<DocumentAgent>;

// @public
export function createAgentFromDocument(document: Document_2): DocumentAgent;

// @public
export function createCollapsedRange(position: Position_2): Range_2;

// @public
export function createCommand<T extends AgentCommand>(command: Omit<T, 'id'>): T;

// @public
export function createRange(start: Position_2, end: Position_2): Range_2;

// @public
export const DEFAULT_AI_ACTIONS: AIAction[];

// @public
export interface DeleteTextCommand extends BaseCommand {
    range: Range_2;
    // (undocumented)
    type: 'deleteText';
}

// @public
export class DocumentAgent {
    constructor(source: Document_2 | ArrayBuffer);
    applyFormatting(range: Range_2, formatting: Partial<TextFormatting>): DocumentAgent;
    applyParagraphFormatting(paragraphIndex: number, formatting: Partial<ParagraphFormatting>): DocumentAgent;
    applyStyle(paragraphIndex: number, styleId: string): DocumentAgent;
    applyVariables(variables?: Record<string, string>): Promise<DocumentAgent>;
    clearPendingVariables(): DocumentAgent;
    deleteRange(range: Range_2): DocumentAgent;
    executeCommands(commands: AgentCommand[]): DocumentAgent;
    static fromBuffer(buffer: DocxInput): Promise<DocumentAgent>;
    static fromDocument(document: Document_2): DocumentAgent;
    getAgentContext(outlineMaxChars?: number): AgentContext;
    getCharacterCount(includeSpaces?: boolean): number;
    getDocument(): Document_2;
    getFormattedText(): FormattedTextSegment[];
    getPageCount(): number;
    getParagraphCount(): number;
    getPendingVariables(): Record<string, string>;
    getStyles(): StyleInfo[];
    getTableCount(): number;
    getText(): string;
    getVariables(): string[];
    getWordCount(): number;
    insertHyperlink(range: Range_2, url: string, options?: InsertHyperlinkOptions): DocumentAgent;
    insertImage(position: Position_2, src: string, options?: InsertImageOptions): DocumentAgent;
    insertParagraphBreak(position: Position_2): DocumentAgent;
    insertTable(position: Position_2, rows: number, cols: number, options?: InsertTableOptions): DocumentAgent;
    insertText(position: Position_2, text: string, options?: InsertTextOptions): DocumentAgent;
    mergeParagraphs(startParagraphIndex: number, count: number): DocumentAgent;
    removeHyperlink(range: Range_2): DocumentAgent;
    replaceRange(range: Range_2, text: string, options?: InsertTextOptions): DocumentAgent;
    setVariable(name: string, value: string): DocumentAgent;
    setVariables(variables: Record<string, string>): DocumentAgent;
    toBlob(mimeType?: string): Promise<Blob>;
    toBuffer(options?: {
        selective?: SelectiveSaveOptions;
    }): Promise<ArrayBuffer>;
}

// @public
export function executeCommand(doc: Document_2, command: AgentCommand): Document_2;

// @public
export function executeCommands(doc: Document_2, commands: AgentCommand[]): Document_2;

// @public
export interface ExtendedSelectionContext extends AgentSelectionContext {
    characterCount?: number;
    contentType?: 'prose' | 'list' | 'heading' | 'table' | 'mixed';
    detectedLanguage?: string;
    documentSummary?: string;
    isMultiParagraph?: boolean;
    paragraphIndices?: number[];
    wordCount?: number;
}

// @public
export function findContentControl(input: Document_2 | DocumentBody, filter: ContentControlFilter): ContentControlInfo | undefined;

// @public
export function findContentControls(input: Document_2 | DocumentBody, filter?: ContentControlFilter): ContentControlInfo[];

// @public
export interface FormatParagraphCommand extends BaseCommand {
    formatting: Partial<ParagraphFormatting>;
    paragraphIndex: number;
    // (undocumented)
    type: 'formatParagraph';
}

// @public
export function formatSdtDate(iso: string, pattern?: string): string;

// @public
export interface FormattedTextSegment {
    formatting?: TextFormatting;
    hyperlinkUrl?: string;
    isHyperlink?: boolean;
    text: string;
}

// @public
export interface FormatTextCommand extends BaseCommand {
    formatting: Partial<TextFormatting>;
    range: Range_2;
    // (undocumented)
    type: 'formatText';
}

// @public
export interface FormattingSummary {
    allFormatting: Partial<TextFormatting>[];
    isConsistent: boolean;
    predominant: Partial<TextFormatting>;
}

// @public
export function getActionDescription(action: AIAction): string;

// @public
export function getActionLabel(action: AIAction): string;

// @public
export function getAgentContext(doc: Document_2, options?: AgentContextOptions): AgentContext;

// @public
export function getBlockIndexForParagraph(body: DocumentBody, paragraphIndex: number): number;

// @public
export function getBodyCharacterCount(body: DocumentBody): number;

// @public
export function getBodyText(body: DocumentBody): string;

// @public
export function getBodyWordCount(body: DocumentBody): number;

// @public
export function getContentControlText(control: BlockSdt): string;

// @public
export function getDocumentSummary(doc: Document_2): string;

// @public
export function getFormattingAtPosition(paragraph: Paragraph, offset: number): Partial<TextFormatting>;

// @public
export function getHyperlinkAtPosition(paragraph: Paragraph, offset: number): Hyperlink | undefined;

// @public
export function getHyperlinkText(hyperlink: Hyperlink): string;

// @public
export function getParagraphAtIndex(body: DocumentBody, index: number): Paragraph | undefined;

// @public
export function getParagraphs(body: DocumentBody): Paragraph[];

// @public
export function getParagraphText(paragraph: Paragraph): string;

// @public
export function getRunText(run: Run): string;

// @public
export function getSelectionFormattingSummary(doc: Document_2, range: Range_2): FormattingSummary;

// @public
export function getTableText(table: Table): string;

// @public
export function getTextAfter(paragraphs: Paragraph[], position: Position_2, maxChars: number): string;

// @public
export function getTextBefore(paragraphs: Paragraph[], position: Position_2, maxChars: number): string;

// @public
export function hasHyperlinks(body: DocumentBody): boolean;

// @public
export function hasImages(body: DocumentBody): boolean;

// @public
export function hasTables(body: DocumentBody): boolean;

// @public
export interface InsertHyperlinkCommand extends BaseCommand {
    displayText?: string;
    range: Range_2;
    tooltip?: string;
    // (undocumented)
    type: 'insertHyperlink';
    url: string;
}

// @public
export interface InsertHyperlinkOptions {
    displayText?: string;
    tooltip?: string;
}

// @public
export interface InsertImageCommand extends BaseCommand {
    alt?: string;
    height?: number;
    position: Position_2;
    src: string;
    // (undocumented)
    type: 'insertImage';
    width?: number;
}

// @public
export interface InsertImageOptions {
    alt?: string;
    height?: number;
    width?: number;
}

// @public
export interface InsertParagraphBreakCommand extends BaseCommand {
    position: Position_2;
    // (undocumented)
    type: 'insertParagraphBreak';
}

// @public
export interface InsertTableCommand extends BaseCommand {
    columns: number;
    data?: string[][];
    hasHeader?: boolean;
    position: Position_2;
    rows: number;
    // (undocumented)
    type: 'insertTable';
}

// @public
export interface InsertTableOptions {
    data?: string[][];
    hasHeader?: boolean;
}

// @public
export interface InsertTextCommand extends BaseCommand {
    formatting?: TextFormatting;
    position: Position_2;
    text: string;
    // (undocumented)
    type: 'insertText';
}

// @public
export interface InsertTextOptions {
    formatting?: TextFormatting;
}

// @public
export function isHeadingStyle(styleId?: string): boolean;

// @public
export function isPositionInHyperlink(paragraph: Paragraph, offset: number): boolean;

// @public
export function isPositionInRange(position: Position_2, range: Range_2): boolean;

// @public
export function isRepeatingSection(props: SdtProperties): boolean;

// @public
export function isRepeatingSectionItem(props: SdtProperties): boolean;

// @public
export interface MergeParagraphsCommand extends BaseCommand {
    count: number;
    paragraphIndex: number;
    // (undocumented)
    type: 'mergeParagraphs';
}

// @public
export interface ParagraphContext {
    fullText: string;
    index: number;
    style?: string;
    wordCount: number;
}

// @public
export interface ParagraphOutline {
    headingLevel?: number;
    index: number;
    isEmpty?: boolean;
    isHeading?: boolean;
    isListItem?: boolean;
    preview: string;
    style?: string;
}

// @public
export function parseHeadingLevel(styleId?: string): number | undefined;

// @public
interface Position_2 {
    contentIndex?: number;
    offset: number;
    paragraphIndex: number;
    sectionIndex?: number;
}
export { Position_2 as Position }

// @public
interface Range_2 {
    collapsed?: boolean;
    end: Position_2;
    start: Position_2;
}
export { Range_2 as Range }

// @public
export function removeContentControl(doc: Document_2, filter: ContentControlFilter, options?: {
    force?: boolean;
    keepContent?: boolean;
}): Document_2;

// @public
export interface RemoveHyperlinkCommand extends BaseCommand {
    range: Range_2;
    // (undocumented)
    type: 'removeHyperlink';
}

// @public
export function removeRepeatingSectionItem(doc: Document_2, filter: ContentControlFilter, index: number): Document_2;

// @public
export class RepeatingSectionError extends Error {
    constructor(message: string);
}

// @public
export interface ReplaceTextCommand extends BaseCommand {
    formatting?: TextFormatting;
    range: Range_2;
    text: string;
    // (undocumented)
    type: 'replaceText';
}

// @public
export interface SectionInfo {
    hasFooter?: boolean;
    hasHeader?: boolean;
    index: number;
    isLandscape?: boolean;
    pageSize?: {
        width: number;
        height: number;
    };
    paragraphCount: number;
}

// @public
export interface SelectionContextOptions {
    contextCharsAfter?: number;
    contextCharsBefore?: number;
    includeDocumentSummary?: boolean;
    includeSuggestions?: boolean;
    maxSuggestions?: number;
}

// @public
export function setContentControlContent(doc: Document_2, filter: ContentControlFilter, replacement: string | BlockContent[], options?: {
    force?: boolean;
}): Document_2;

// @public
export function setContentControlValue(doc: Document_2, filter: ContentControlFilter, value: ContentControlValue, options?: {
    force?: boolean;
}): Document_2;

// @public
export interface SetVariableCommand extends BaseCommand {
    name: string;
    // (undocumented)
    type: 'setVariable';
    value: string;
}

// @public
export interface SplitParagraphCommand extends BaseCommand {
    position: Position_2;
    // (undocumented)
    type: 'splitParagraph';
}

// @public
export interface StyleInfo {
    builtIn?: boolean;
    id: string;
    name: string;
    type: 'paragraph' | 'character' | 'table';
}

// @public
export interface SuggestedAction {
    description?: string;
    icon?: string;
    id: string;
    label: string;
    priority?: number;
}

```
