"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBundledAxeCoreVersions = getBundledAxeCoreVersions;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const constantsNode_1 = require("./constantsNode");
const semver_1 = __importDefault(require("semver"));
const semver_2 = require("./semver");
const createDebugger_1 = __importDefault(require("../createDebugger"));
const debugLogger = (0, createDebugger_1.default)('config:getBundledAxeCoreVersions');
function getBundledAxeCoreVersions() {
    const mapperPath = path_1.default.join(constantsNode_1.PATH_TO_EXTENSION, 'axe-versions-mapper.js');
    const content = fs_1.default.readFileSync(mapperPath, 'utf-8');
    const match = content.match(/=\s*(\{[\s\S]*\})/);
    if (!match) {
        debugLogger(`Could not load axe-core versions because no versions object was found in the module "${mapperPath}".`);
        return [];
    }
    const versions = JSON.parse(match[1]);
    const unique = [...new Set(Object.values(versions))];
    return unique.filter(v => (0, semver_2.isValidProductionSemVer)(v) && semver_1.default.compare(v, semver_2.MIN_AXE_CORE_VERSION) >= 0);
}
exports.default = { getBundledAxeCoreVersions };
//# sourceMappingURL=getBundledAxeCoreVersions.js.map