"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatSettingsPathList = exports.findCodexTranslatorUrlPaths = exports.CODEX_TRANSLATOR_URL_MARKER = void 0;
exports.CODEX_TRANSLATOR_URL_MARKER = '/api/provider/codex';
function formatSettingsPathSegment(basePath, segment) {
    if (typeof segment === 'number') {
        return `${basePath}[${segment}]`;
    }
    if (/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(segment)) {
        return basePath ? `${basePath}.${segment}` : segment;
    }
    return `${basePath}[${JSON.stringify(segment)}]`;
}
function findCodexTranslatorUrlPaths(value, path = '') {
    if (typeof value === 'string') {
        return value.includes(exports.CODEX_TRANSLATOR_URL_MARKER) ? [path || '(root)'] : [];
    }
    if (Array.isArray(value)) {
        return value.flatMap((item, index) => findCodexTranslatorUrlPaths(item, formatSettingsPathSegment(path, index)));
    }
    if (typeof value === 'object' && value !== null) {
        return Object.entries(value).flatMap(([key, item]) => findCodexTranslatorUrlPaths(item, formatSettingsPathSegment(path, key)));
    }
    return [];
}
exports.findCodexTranslatorUrlPaths = findCodexTranslatorUrlPaths;
function formatSettingsPathList(paths) {
    const visiblePaths = paths.slice(0, 5);
    const remainingCount = paths.length - visiblePaths.length;
    return remainingCount > 0
        ? `${visiblePaths.join(', ')} (+${remainingCount} more)`
        : visiblePaths.join(', ');
}
exports.formatSettingsPathList = formatSettingsPathList;
//# sourceMappingURL=stale-codex-translator-settings.js.map