"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PackageNameMatcher = void 0;
const tslib_1 = require("tslib");
const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
const logger_1 = require("../../logger");
const base_1 = require("./base");
class PackageNameMatcher extends base_1.Matcher {
    matches({ depName, packageName }, packageRule) {
        const { matchPackageNames } = packageRule;
        if (is_1.default.undefined(matchPackageNames)) {
            return null;
        }
        if (is_1.default.undefined(depName)) {
            return false;
        }
        if (is_1.default.string(packageName) && matchPackageNames.includes(packageName)) {
            return true;
        }
        if (matchPackageNames.includes(depName)) {
            logger_1.logger.once.warn({ packageRule, packageName, depName }, 'Use matchDepNames instead of matchPackageNames');
            return true;
        }
        return false;
    }
    excludes({ depName }, { excludePackageNames }) {
        if (is_1.default.undefined(excludePackageNames)) {
            return null;
        }
        if (is_1.default.undefined(depName)) {
            return false;
        }
        return excludePackageNames.includes(depName);
    }
}
exports.PackageNameMatcher = PackageNameMatcher;
//# sourceMappingURL=package-names.js.map