"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RegexPatternMatcher = exports.StringPatternMatcher = void 0;
exports.createPatternMatcher = createPatternMatcher;
class StringPatternMatcher {
    pattern;
    constructor(pattern) {
        this.pattern = pattern;
    }
    matches(toolName) {
        const regexPattern = this.pattern
            .replace(/[.+^${}()|[\]\\]/g, "\\$&")
            .replace(/\*/g, ".*")
            .replace(/\?/g, ".");
        const regex = new RegExp(`^${regexPattern}$`);
        return regex.test(toolName);
    }
}
exports.StringPatternMatcher = StringPatternMatcher;
class RegexPatternMatcher {
    pattern;
    constructor(pattern) {
        this.pattern = pattern;
    }
    matches(toolName) {
        return this.pattern.test(toolName);
    }
}
exports.RegexPatternMatcher = RegexPatternMatcher;
function createPatternMatcher(pattern) {
    if (typeof pattern === "string") {
        return new StringPatternMatcher(pattern);
    }
    else {
        return new RegexPatternMatcher(pattern);
    }
}
//# sourceMappingURL=types.js.map