"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const typescript_1 = require("typescript");
const MODULE_REGEX = /import |export |module.exports|exports/;
const REQUIRE_REGEX = /require\(([a-zA-Z0-9])+\)/;
const EXPORT_REGEX = /export |module.exports|exports/;
const hasNodeGlobalImpact = (node) => node.kind === typescript_1.SyntaxKind.DeclareKeyword ? true : exports.getNodes(node).some(hasNodeGlobalImpact);
const hasModules = ({ text }) => MODULE_REGEX.test(text) || REQUIRE_REGEX.test(text);
exports.hasExports = ({ text }) => EXPORT_REGEX.test(text);
exports.getNodes = (item) => {
    const nodes = [];
    item.forEachChild((node) => {
        nodes.push(node);
    });
    return nodes;
};
exports.hasGlobalImpact = (sourceFile) => exports.getNodes(sourceFile).some(hasNodeGlobalImpact) || !hasModules(sourceFile);
exports.getDependencies = (sourceFile) => {
    const resolvedModules = sourceFile.resolvedModules;
    if (resolvedModules) {
        return Array.from(resolvedModules.values())
            .filter((resolved) => Boolean(resolved))
            .map((resolved) => resolved.resolvedFileName);
    }
    return [];
};
//# sourceMappingURL=dependencies.js.map