"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.STRATEGY_CATEGORIES = void 0;
exports.getPluginIdsShownInSecurityConfigUi = getPluginIdsShownInSecurityConfigUi;
exports.getStrategyIdsShownInSecurityConfigUi = getStrategyIdsShownInSecurityConfigUi;
exports.getSecurityConfigArgusUiPluginDisplayNames = getSecurityConfigArgusUiPluginDisplayNames;
exports.getSecurityConfigArgusUiStrategyDisplayNames = getSecurityConfigArgusUiStrategyDisplayNames;
exports.getSecurityConfigArgusUiRiskCategorySectionNames = getSecurityConfigArgusUiRiskCategorySectionNames;
/**
 * Plugins and strategies actually shown in **Security Config → Create with Argus** (and red team setup).
 * Used by the Argus `securityconfig` system prompt so the model only sees UI-visible ids.
 *
 * **STRATEGY_CATEGORIES** must stay aligned with `StrategiesPicker` / setup strategy UI
 * (previously defined in `src/app/src/modules/redteam/setup/constants/constant.ts`).
 */
const metadata_1 = require("./metadata");
const plugins_1 = require("./plugins");
const strategies_1 = require("./strategies");
/** Strategy groups shown in security setup + Argus security-config editor (non-commented ids only). */
exports.STRATEGY_CATEGORIES = {
    'Single Turn Strategies': ['basic', 'jailbreak', 'jailbreak:tree', 'retry', 'multilingual'],
    'Multi Turn Strategies': ['crescendo', 'mischievous-user'],
    'Jailbreak Strategies': ['prompt-injection'],
    'Encoding Strategies': [
        'base64',
        'camelcase',
        'emoji',
        'hex',
        'homoglyph',
        'leetspeak',
        'math-prompt',
        'morse',
        'piglatin',
        'rot13',
        'other-encodings',
    ],
    'Multimodal Strategies': ['audio', 'image', 'video'],
};
const ALL_PLUGINS_SET = new Set(plugins_1.ALL_PLUGINS);
/** Plugin ids listed under vulnerability categories when intersected with ALL_PLUGINS (matches PluginsCategoryEditor). */
function getPluginIdsShownInSecurityConfigUi() {
    const ordered = new Set();
    for (const plugins of Object.values(metadata_1.riskCategories)) {
        for (const p of plugins) {
            const id = String(p);
            if (ALL_PLUGINS_SET.has(id)) {
                ordered.add(id);
            }
        }
    }
    return [...ordered].sort();
}
/** Strategy ids shown in StrategiesPicker (STRATEGY_CATEGORIES ∩ ALL_STRATEGIES, stable order). */
function getStrategyIdsShownInSecurityConfigUi() {
    const allowed = new Set(strategies_1.ALL_STRATEGIES);
    const ordered = [];
    for (const [, groupIds] of Object.entries(exports.STRATEGY_CATEGORIES)) {
        for (const id of groupIds) {
            if (id === 'default') {
                continue;
            }
            if (!allowed.has(id)) {
                continue;
            }
            if (!ordered.includes(id)) {
                ordered.push(id);
            }
        }
    }
    return ordered;
}
/** displayNameOverrides restricted to UI-visible vulnerability plugin ids. */
function getSecurityConfigArgusUiPluginDisplayNames() {
    const pluginIds = new Set(getPluginIdsShownInSecurityConfigUi());
    const out = {};
    for (const id of pluginIds) {
        const label = metadata_1.displayNameOverrides[id];
        if (label) {
            out[id] = label;
        }
    }
    return out;
}
/** strategyDisplayNames restricted to UI-visible strategy ids. */
function getSecurityConfigArgusUiStrategyDisplayNames() {
    const ids = new Set(getStrategyIdsShownInSecurityConfigUi());
    const out = {};
    for (const id of ids) {
        const label = metadata_1.strategyDisplayNames[id];
        if (label) {
            out[id] = label;
        }
    }
    return out;
}
/** Top-level risk category names that contain at least one UI-visible plugin. */
function getSecurityConfigArgusUiRiskCategorySectionNames() {
    const allowedPlugins = new Set(getPluginIdsShownInSecurityConfigUi());
    const names = [];
    for (const [catName, plugins] of Object.entries(metadata_1.riskCategories)) {
        if (plugins.some((p) => allowedPlugins.has(String(p)))) {
            names.push(catName);
        }
    }
    return names;
}
//# sourceMappingURL=securityConfigArgusUiCatalog.js.map