"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.OffsetListFactory = void 0;
/**
 * Helper class for constructing an offset list that...
 *
 * - Does not insert offsets if there is no content after them
 *
 * - Does not insert 0-sized offsets
 *
 * - Merges runs of offsets together
 */
class OffsetListFactory {
    constructor() {
        this.offset = 0;
        this.list = [];
    }
    push(...offsetOrContent) {
        for (const item of offsetOrContent) {
            if (typeof item === "number") {
                this.pushOffset(item);
            }
            else {
                this.pushContent(item);
            }
        }
    }
    pushOffset(offset) {
        this.offset += offset;
    }
    pushContent(content) {
        if (this.offset > 0) {
            this.list.push(this.offset);
            this.offset = 0;
        }
        this.list.push(content);
    }
}
exports.OffsetListFactory = OffsetListFactory;
//# sourceMappingURL=offsetList.js.map