"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getIntention = exports.NodeExistenceState = exports.isolatedFieldChangeRebaser = exports.referenceFreeFieldChangeRebaser = void 0;
const util_1 = require("../../util");
/**
 * Helper for creating a {@link FieldChangeRebaser} which does not need access to revision tags.
 * This should only be used for fields where the child nodes cannot be edited.
 */
function referenceFreeFieldChangeRebaser(data) {
    return isolatedFieldChangeRebaser({
        compose: (changes, _composeChild, _genId) => data.compose(changes.map((c) => c.change)),
        invert: (change, _invertChild, _genId) => data.invert(change.change),
        rebase: (change, over, _rebaseChild, _genId) => data.rebase(change, over.change),
    });
}
exports.referenceFreeFieldChangeRebaser = referenceFreeFieldChangeRebaser;
function isolatedFieldChangeRebaser(data) {
    return {
        ...data,
        amendCompose: () => (0, util_1.fail)("Not implemented"),
        amendInvert: () => (0, util_1.fail)("Not implemented"),
        amendRebase: (change) => change,
    };
}
exports.isolatedFieldChangeRebaser = isolatedFieldChangeRebaser;
/**
 * @alpha
 */
var NodeExistenceState;
(function (NodeExistenceState) {
    NodeExistenceState[NodeExistenceState["Alive"] = 0] = "Alive";
    NodeExistenceState[NodeExistenceState["Dead"] = 1] = "Dead";
})(NodeExistenceState || (exports.NodeExistenceState = NodeExistenceState = {}));
/**
 * @alpha
 */
function getIntention(rev, revisionMetadata) {
    return revisionMetadata.tryGetInfo(rev)?.rollbackOf ?? rev;
}
exports.getIntention = getIntention;
//# sourceMappingURL=fieldChangeHandler.js.map