"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.planManagedFileWrite = planManagedFileWrite;
const node_fs_1 = __importDefault(require("node:fs"));
function planManagedFileWrite(options) {
    if (!node_fs_1.default.existsSync(options.absolutePath)) {
        return {
            path: options.relativePath,
            action: "create",
            writeOutcome: "create",
            reason: "missing",
            recoveryGuidance: []
        };
    }
    const currentContent = node_fs_1.default.readFileSync(options.absolutePath, "utf8");
    if (currentContent === options.expectedContent) {
        return {
            path: options.relativePath,
            action: "noop",
            writeOutcome: "keep",
            reason: "matches-expected",
            recoveryGuidance: []
        };
    }
    if (options.force) {
        return {
            path: options.relativePath,
            action: "overwrite",
            writeOutcome: "overwrite",
            reason: "force-overwrite",
            recoveryGuidance: []
        };
    }
    return {
        path: options.relativePath,
        action: "noop",
        writeOutcome: "keep",
        reason: "preserved-existing",
        recoveryGuidance: [
            "Compare the existing file with the packaged default before replacing it.",
            "Rerun with explicit force only when replacement is intended.",
            "Use repository history or backups to recover prior local content."
        ]
    };
}
