import * as Y from 'yjs';
import * as types from 'open-collaboration-protocol';
export interface YTextChange {
    start: number;
    end: number;
    text: string;
}
export declare namespace YTextChange {
    function sort(changes: YTextChange[]): YTextChange[];
}
export interface YTextChangeDelta {
    insert?: string | object | Y.AbstractType<any>;
    delete?: number;
    retain?: number;
}
export declare namespace YTextChangeDelta {
    function isInsert(delta: YTextChangeDelta): delta is {
        insert: string;
    };
    function isDelete(delta: YTextChangeDelta): delta is {
        delete: number;
    };
    function isRetain(delta: YTextChangeDelta): delta is {
        retain: number;
    };
    function toChanges(delta: YTextChangeDelta[]): YTextChange[];
}
export interface YTextChangeEvent {
    changes: YTextChange[] | string;
}
export type YjsTextDocumentChangedCallback = (changes: YTextChange[]) => Promise<void>;
export declare class YjsNormalizedTextDocument implements types.Disposable {
    private _yjsText;
    private _text;
    private _textLength;
    private _normalizedLength;
    private _changeSets;
    private _offsets;
    private observer;
    constructor(yjsText: Y.Text, callback: YjsTextDocumentChangedCallback);
    private observe;
    dispose(): void;
    originalOffset(normalizedOffset: number): number;
    originalOffsetAt(position: types.Position): number;
    private offsetAt;
    positionAtNormalized(normalizedOffset: number): types.Position;
    positionAt(offset: number): types.Position;
    normalizedOffset(offset: number): number;
    normalizedOffsetAt(position: types.Position): number;
    update(event: YTextChangeEvent): void;
    private shouldApply;
    private doUpdate;
    /**
     * If we are within an update, offsets are unavailable.
     * Therefore, we need a secondary method to count the normalized offsets up to a certain offset in the text.
     *
     * Note that this method is not very efficient, as it needs to iterate over the entire text.
     * However, in 99% of use cases, it is only called once. Making it fast enough for the common case.
     */
    private countNormalizedOffsets;
    private normalize;
    private ensureBeforeEOL;
    private findLineOffset;
    private getLineOffsets;
}
//# sourceMappingURL=yjs-normalized-text.d.ts.map