"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDisabledSkills = getDisabledSkills;
exports.toggleSkill = toggleSkill;
exports.isSkillActive = isSkillActive;
const fs_1 = __importDefault(require("fs"));
const paths_1 = require("../config/paths");
let disabledSkillsCache = null;
function getDisabledSkillsFile() {
    return (0, paths_1.getPath)('disabled_skills.json');
}
function getDisabledSkills() {
    if (disabledSkillsCache !== null) {
        return disabledSkillsCache;
    }
    const filepath = getDisabledSkillsFile();
    if (!fs_1.default.existsSync(filepath)) {
        disabledSkillsCache = [];
        return disabledSkillsCache;
    }
    try {
        const data = fs_1.default.readFileSync(filepath, 'utf-8');
        disabledSkillsCache = JSON.parse(data);
        if (!Array.isArray(disabledSkillsCache))
            disabledSkillsCache = [];
        return disabledSkillsCache;
    }
    catch (e) {
        disabledSkillsCache = [];
        return [];
    }
}
function toggleSkill(skillName, active) {
    const current = new Set(getDisabledSkills());
    if (active) {
        current.delete(skillName); // Remove from disabled list to activate
    }
    else {
        current.add(skillName); // Add to disabled list to deactivate
    }
    disabledSkillsCache = Array.from(current);
    fs_1.default.writeFileSync(getDisabledSkillsFile(), JSON.stringify(disabledSkillsCache, null, 2));
}
function isSkillActive(skillName) {
    const disabled = getDisabledSkills();
    return !disabled.includes(skillName);
}
