"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultCursor = exports.defaultCursorPlaceholder = exports.Cursor = void 0;
class Cursor {
    constructor(value) {
        this.value = value;
    }
    insertAt(str, pos) {
        let line = pos.line + 1;
        let idx = 0;
        for (; idx < str.length && line > 1; idx++) {
            if (str.charAt(idx) === '\n') {
                line--;
            }
        }
        idx += pos.character;
        const prefix = str.slice(0, idx);
        const suffix = str.slice(idx);
        return `${prefix}${this.value}${suffix}`;
    }
    isSuffixOf(str) {
        return str.endsWith(this.value);
    }
    isIn(str) {
        return str.includes(this.value);
    }
    isEqualTo(str) {
        return str === this.value;
    }
    revert(str) {
        return str.replace(this.value, '');
    }
}
exports.Cursor = Cursor;
exports.defaultCursorPlaceholder = '_CURSOR_';
exports.defaultCursor = new Cursor(exports.defaultCursorPlaceholder);
//# sourceMappingURL=cursor.js.map