"use strict";
/**
 * Copyright: (c) Myia SAS 2026.
 * This file and its contents are licensed under the AGPLv3 License.
 * Please see the LICENSE file at the root of this repository
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCjsArtifactDetector = createCjsArtifactDetector;
function createCjsArtifactDetector(t) {
    const isRequireLike = (node) => {
        if (!node || !t.isCallExpression(node))
            return false;
        const callee = node.callee;
        if (!t.isIdentifier(callee))
            return false;
        if (callee.name === 'require')
            return true;
        if (/^_interop/.test(callee.name) && node.arguments.length > 0) {
            return isRequireLike(node.arguments[0]);
        }
        return false;
    };
    const isGeneratedModuleStatement = (node) => {
        if (t.isVariableDeclaration(node)) {
            return node.declarations.every((d) => isRequireLike(d.init));
        }
        return false;
    };
    return { isRequireLike, isGeneratedModuleStatement };
}
