import type { IDocsLatexFormulaConfig } from '@univerjs-pro/docs-latex';
/**
 * Optional visual properties used when a document LaTeX formula is created.
 *
 * The underlying custom-range id is generated by the insert command and is not
 * part of the public creation contract.
 */
export interface IDocsLatexCreateFacadeOptions {
    /**
     * Optional formula visual properties.
     */
    properties?: Partial<Omit<IDocsLatexFormulaConfig, 'latex'>>;
}
/**
 * Options for updating an existing LaTeX formula through the formula facade.
 *
 * @example
 * ```ts
 * const univerAPI = FUniver.newAPI(univer);
 * const document = univerAPI.getActiveDocument();
 * if (!document) throw new Error('No active document');
 * const formula = document.getLatexFormulas()[0];
 * if (!formula) throw new Error('No LaTeX formula');
 * if (!formula.update({ latex: '\\frac{a}{b}' })) throw new Error('Cannot update LaTeX formula');
 * ```
 */
export interface IDocsLatexUpdateFacadeOptions {
    /**
     * Replacement editable LaTeX source.
     */
    latex: string;
    /**
     * Optional formula visual property patch.
     */
    properties?: Partial<Omit<IDocsLatexFormulaConfig, 'latex'>>;
}
/**
 * Query used to search LaTeX formulas in a document.
 *
 * @example
 * ```ts
 * const univerAPI = FUniver.newAPI(univer);
 * const document = univerAPI.getActiveDocument();
 * if (!document) throw new Error('No active document');
 * const formulas = document.findLatexFormulas({ latex: 'frac' });
 * console.log(formulas.length);
 * ```
 */
export interface IDocsLatexFindQuery {
    /**
     * Source text that must be contained in the formula.
     */
    latex?: string;
    /**
     * Custom range id to match exactly.
     */
    rangeId?: string;
}
/**
 * Data-stream range for a LaTeX formula.
 *
 * @example
 * ```ts
 * const univerAPI = FUniver.newAPI(univer);
 * const document = univerAPI.getActiveDocument();
 * if (!document) throw new Error('No active document');
 * const formula = document.getLatexFormulas()[0];
 * if (!formula) throw new Error('No LaTeX formula');
 * const range = formula.getRange();
 * if (!range) throw new Error('LaTeX formula has no range');
 * console.log(range.startOffset, range.endOffset, range.segmentId);
 * ```
 */
export interface IDocsLatexRange {
    /**
     * Exclusive end offset of the formula custom range.
     */
    endOffset: number;
    /**
     * Internal custom-range id generated by the insert command.
     */
    rangeId: string;
    /**
     * Header or footer segment id. The main document body uses an empty string.
     */
    segmentId: string;
    /**
     * Inclusive start offset of the formula custom range.
     */
    startOffset: number;
}
export interface IDocsLatexContext {
    /**
     * Text in the containing paragraph before the formula.
     */
    before: string;
    /**
     * Text in the containing paragraph after the formula.
     */
    after: string;
}
/**
 * Agent-friendly description of a LaTeX formula.
 *
 * @example
 * ```ts
 * const univerAPI = FUniver.newAPI(univer);
 * const document = univerAPI.getActiveDocument();
 * if (!document) throw new Error('No active document');
 * const formula = document.getLatexFormulas()[0];
 * if (!formula) throw new Error('No LaTeX formula');
 * const info = formula.describe();
 * if (!info) throw new Error('LaTeX formula no longer exists');
 * console.log(info.type, info.latex);
 * ```
 */
export interface IDocsLatexInfo extends IDocsLatexRange {
    /**
     * Normalized formula configuration.
     */
    config: IDocsLatexFormulaConfig;
    /**
     * Formula context inside its containing paragraph.
     */
    context: IDocsLatexContext;
    /**
     * Editable LaTeX source.
     */
    latex: string;
    /**
     * Persisted id of the containing paragraph, or `null` when the paragraph cannot be resolved.
     */
    paragraphId: string | null;
    /**
     * Stable discriminator for LaTeX formula descriptions.
     */
    type: 'latex';
}
