/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
/**
 * An IDefaultEditBuilder implementation based on another IDefaultEditBuilder that uses a different content type for insertions.
 */
export class MappedEditBuilder {
    constructor(baseBuilder, mapDelegate) {
        this.baseBuilder = baseBuilder;
        this.mapDelegate = mapDelegate;
    }
    valueField(field) {
        const baseField = this.baseBuilder.valueField(field);
        return {
            set: (newContent) => {
                const mappedContent = this.mapDelegate(newContent);
                baseField.set(mappedContent);
            },
        };
    }
    optionalField(field) {
        const baseField = this.baseBuilder.optionalField(field);
        return {
            set: (newContent, wasEmpty) => {
                const mappedContent = newContent === undefined ? undefined : this.mapDelegate(newContent);
                baseField.set(mappedContent, wasEmpty);
            },
        };
    }
    sequenceField(field) {
        const baseField = this.baseBuilder.sequenceField(field);
        return {
            insert: (index, content) => {
                const mappedContent = this.mapDelegate(content);
                baseField.insert(index, mappedContent);
            },
            remove: (index, count) => {
                baseField.remove(index, count);
            },
        };
    }
    move(sourceField, sourceIndex, count, destinationField, destinationIndex) {
        this.baseBuilder.move(sourceField, sourceIndex, count, destinationField, destinationIndex);
    }
    addNodeExistsConstraint(path) {
        this.baseBuilder.addNodeExistsConstraint(path);
    }
    addNodeExistsConstraintOnRevert(path) {
        this.baseBuilder.addNodeExistsConstraintOnRevert(path);
    }
    addNoChangeConstraint() {
        this.baseBuilder.addNoChangeConstraint();
    }
    addNoChangeConstraintOnRevert() {
        this.baseBuilder.addNoChangeConstraintOnRevert();
    }
}
//# sourceMappingURL=mappedEditBuilder.js.map