"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaults = getDefaults;
exports.setDefaults = setDefaults;
const node_fs_1 = require("node:fs");
const node_os_1 = require("node:os");
const node_path_1 = require("node:path");
const PREFS_DIR = (0, node_path_1.join)((0, node_os_1.homedir)(), ".cockpit");
const DEFAULTS_FILE = (0, node_path_1.join)(PREFS_DIR, "defaults.json");
const fallback = {
    thinkingLevel: "high",
    bypassAllPermissions: false,
    diffStyle: "split",
    dismissKeyboardOnSend: true,
    thinkingExpanded: false,
    readExpanded: false,
    editExpanded: false,
    toolCallsExpanded: false,
    model: "sonnet",
    messageStitching: true,
    reviewsEnabled: true,
};
function getDefaults() {
    try {
        return { ...fallback, ...JSON.parse((0, node_fs_1.readFileSync)(DEFAULTS_FILE, "utf-8")) };
    }
    catch {
        return { ...fallback };
    }
}
function setDefaults(partial) {
    const current = getDefaults();
    const updated = { ...current, ...partial };
    try {
        (0, node_fs_1.mkdirSync)(PREFS_DIR, { recursive: true });
        (0, node_fs_1.writeFileSync)(DEFAULTS_FILE, JSON.stringify(updated, null, 2) + "\n");
    }
    catch {
        // best effort
    }
    return updated;
}
