Object.defineProperty(exports, "__esModule", { value: true });
class HtmlToOperationLogMapping {
    constructor(parts) {
        this.parts = parts;
    }
    getOriginAtCharacterIndex(charIndex) {
        let charCounter = 0;
        let partIndex = 0;
        while (charCounter <= charIndex) {
            const part = this.parts[partIndex];
            const [text, origin] = part;
            charCounter += text.length;
            partIndex++;
            if (partIndex > this.parts.length + 1) {
                throw Error("not found");
            }
        }
        const matchingPartIndex = partIndex - 1;
        const matchingPart = this.parts[matchingPartIndex];
        charCounter -= matchingPart[0].length;
        return {
            charIndex: charIndex - charCounter,
            origin: matchingPart[1]
        };
    }
    getHtml() {
        return this.parts.map(p => p[0]).join("");
    }
}
exports.default = HtmlToOperationLogMapping;
//# sourceMappingURL=HtmlToOperationLogMapping.js.map