/** * IndexTracker manages UTF-16 code unit offset calculations for Google Docs API. * * Google Docs uses UTF-16 code unit offsets for all index-based operations. * This class handles: * - Converting between JavaScript string positions and UTF-16 code unit positions * - Tracking cumulative offset deltas for multi-edit batchUpdate calls * - Ensuring edits are applied in reverse index order */ export declare class IndexTracker { private deltas; /** * Count UTF-16 code units in a string. * JavaScript strings are already UTF-16, so .length gives code units. * This is explicitly named for clarity. */ static utf16Length(text: string): number; /** * Convert a JavaScript string index (code unit offset) to a * Google Docs absolute index, accounting for accumulated deltas. */ adjustIndex(originalIndex: number): number; /** * Record a text deletion at a given index range. * Subsequent index adjustments will account for this deletion. */ recordDeletion(startIndex: number, endIndex: number): void; /** * Record a text insertion at a given index. * Subsequent index adjustments will account for this insertion. */ recordInsertion(index: number, text: string): void; /** * Record a replacement (deletion + insertion) at a given range. * Returns the net shift for this operation. */ recordReplacement(startIndex: number, endIndex: number, newText: string): number; /** * Sort edit operations in reverse index order for batchUpdate. * Google Docs requires edits at higher indices to be applied first * to avoid index invalidation. */ static sortEditsReverseOrder(edits: T[]): T[]; /** * Check if a character at a given position in a string is part of a surrogate pair. * Useful for ensuring we don't split surrogate pairs in index calculations. */ static isSurrogatePair(text: string, index: number): boolean; /** * Count the number of surrogate pairs (supplementary characters) in a string. * Each surrogate pair takes 2 UTF-16 code units but represents 1 Unicode code point. */ static countSurrogatePairs(text: string): number; /** * Convert a Unicode code point offset to a UTF-16 code unit offset. * Needed when converting from user-visible character positions to API indices. */ static codePointOffsetToUtf16(text: string, codePointOffset: number): number; /** Reset all accumulated deltas */ reset(): void; } //# sourceMappingURL=index-tracker.d.ts.map