'use strict'; var chunkYW7AIVNG_cjs = require('./chunk-YW7AIVNG.cjs'); var url = require('url'); var rollupPlugin = require('@optimize-lodash/rollup-plugin'); var commonjs = require('@rollup/plugin-commonjs'); var json = require('@rollup/plugin-json'); var rollup = require('rollup'); var babel = require('@babel/core'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n.default = e; return Object.freeze(n); } var commonjs__default = /*#__PURE__*/_interopDefault(commonjs); var json__default = /*#__PURE__*/_interopDefault(json); var babel__namespace = /*#__PURE__*/_interopNamespace(babel); function removeAllOptionsFromMastraExcept(result, option, logger) { const t = babel__namespace.default.types; return { name: "remove-all-except-" + option + "-config", visitor: { ExportNamedDeclaration: { // remove all exports exit(path) { path.remove(); } }, NewExpression(path, state) { const varDeclaratorPath = path.findParent((path2) => t.isVariableDeclarator(path2.node)); if (!varDeclaratorPath) { return; } const parentNode = path.parentPath.node; if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") { return; } let mastraArgs = t.objectExpression([]); if (t.isObjectExpression(path.node.arguments[0])) { mastraArgs = path.node.arguments[0]; } let configProperty = mastraArgs.properties.find( (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === option ); let configValue = t.objectExpression([]); const programPath = path.scope.getProgramParent().path; if (!programPath) { return; } if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) { result.hasCustomConfig = true; configValue = configProperty.value; if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) { const configBinding = state.file.scope.getBinding(option); if (configBinding && t.isVariableDeclarator(configBinding.path.node)) { const id = path.scope.generateUidIdentifier(option); configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init)); configValue = id; } } } const exportDeclaration = t.exportNamedDeclaration( t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), configValue)]), [] ); programPath.node.body.push(exportDeclaration); }, Program: { exit(path) { const hasExport = path.node.body.some( (node) => node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration" ); if (!hasExport) { if (logger) { logger.warn("Mastra config could not be extracted", { option, details: "Please make sure your entry file looks like this:\nexport const mastra = new Mastra({\n