"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SYSTEM_PROMPT_FILE_EXTENSION = exports.SYSTEM_PROMPTS_DIRECTORY_NAME = void 0;
exports.getRepoSystemPromptsDirectoryPath = getRepoSystemPromptsDirectoryPath;
exports.normalizeSystemPromptPath = normalizeSystemPromptPath;
const node_path_1 = __importDefault(require("node:path"));
const branding_1 = require("../core/branding");
exports.SYSTEM_PROMPTS_DIRECTORY_NAME = "system-prompts";
exports.SYSTEM_PROMPT_FILE_EXTENSION = ".md";
function getRepoSystemPromptsDirectoryPath(repoRoot) {
    return node_path_1.default.join(repoRoot, branding_1.REPO_HOME_DIRECTORY_NAME, exports.SYSTEM_PROMPTS_DIRECTORY_NAME);
}
function normalizeSystemPromptPath(value) {
    const trimmed = value.trim();
    if (trimmed.length === 0 ||
        node_path_1.default.isAbsolute(trimmed) ||
        trimmed.includes("\\")) {
        return null;
    }
    const normalized = node_path_1.default.posix.normalize(trimmed);
    if (normalized.length === 0 ||
        normalized === "." ||
        normalized !== trimmed ||
        normalized.startsWith("../") ||
        normalized.includes("/../") ||
        normalized.split("/").some((segment) => {
            return segment === "." || segment === ".." || segment.length === 0;
        }) ||
        !normalized.endsWith(exports.SYSTEM_PROMPT_FILE_EXTENSION)) {
        return null;
    }
    return normalized;
}
