export function createLineLookup(src) {
    const newlineIndexes = [];
    for (let indice = 0; indice < src.length; indice++) {
        if (src.charCodeAt(indice) === 10)
            newlineIndexes.push(indice);
    }
    const lineAt = (index) => {
        if (!index || index <= 0)
            return 1;
        const clampedIndex = Math.min(src.length, Math.max(0, index));
        let lo = 0;
        let hi = newlineIndexes.length;
        while (lo < hi) {
            const mid = lo + hi >>> 1;
            if (newlineIndexes[mid] < clampedIndex)
                lo = mid + 1;
            else
                hi = mid;
        }
        return lo + 1;
    };
    return {
        lineAt
    };
}
//# sourceMappingURL=line-lookup.js.map