'use strict'; var module$1 = require('module'); var path = require('path'); // src/build/utils.ts function getNodeResolveOptions(platform) { if (platform === "browser") { return { preferBuiltins: false, browser: true, exportConditions: ["browser", "worker", "default"] }; } return { preferBuiltins: true, exportConditions: ["node"] }; } function detectRuntime() { if (process.versions?.bun) { return "bun"; } return "node"; } function isDependencyPartOfPackage(dep, packageName) { if (dep === packageName) { return true; } return dep.startsWith(`${packageName}/`); } function getPackageName(id) { const parts = id.split("/"); if (id.startsWith("@")) { return parts.slice(0, 2).join("/"); } return parts[0]; } function hasImportProtocol(specifier) { if (/^[A-Za-z]:[\\/]/.test(specifier)) { return false; } return /^[A-Za-z][A-Za-z\d+.-]*:/.test(specifier); } var DEFAULT_PROTOCOL_IMPORT_EXCLUDE_LIST = ["node:"]; function isExternalProtocolImport(specifier, excludeList = DEFAULT_PROTOCOL_IMPORT_EXCLUDE_LIST) { if (!hasImportProtocol(specifier)) { return false; } return !excludeList.some((prefix) => specifier.startsWith(prefix)); } function isRelativeImportSpecifier(specifier) { return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../"); } function isAbsolutePathSpecifier(specifier) { return specifier.startsWith("/") || specifier.startsWith("\\\\") || /^[A-Za-z]:[\\/]/.test(specifier); } function getCompiledDepCachePath(rootPath, packageName) { return slash(path.join(rootPath, "node_modules", ".cache", packageName)); } function slash(path) { const isExtendedLengthPath = path.startsWith("\\\\?\\"); if (isExtendedLengthPath) { return path; } return path.replaceAll("\\", "/"); } function rollupSafeName(name, rootDir) { const rel = path.relative(rootDir, name); let entry = slash(rel); entry = entry.replace(/^(\.\.\/)+/, ""); entry = entry.replace(/^\/+/, ""); entry = entry.replace(/^[A-Za-z]:\//, ""); if (!entry) { entry = slash(path.basename(name)); } return entry; } function normalizeStudioBase(studioBase) { studioBase = studioBase.trim(); if (studioBase.includes("..") || studioBase.includes("?") || studioBase.includes("#")) { throw new Error(`Invalid base path: "${studioBase}". Base path cannot contain '..', '?', or '#'`); } studioBase = studioBase.replace(/\/+/g, "/"); if (studioBase === "/" || studioBase === "") { return ""; } if (studioBase.endsWith("/")) { studioBase = studioBase.slice(0, -1); } if (!studioBase.startsWith("/")) { studioBase = `/${studioBase}`; } return studioBase; } function injectStudioHtmlConfig(html, config) { html = html.replace(`'%%MASTRA_SERVER_HOST%%'`, config.host); html = html.replace(`'%%MASTRA_SERVER_PORT%%'`, config.port); html = html.replace(`'%%MASTRA_SERVER_PROTOCOL%%'`, config.protocol); html = html.replace(`'%%MASTRA_API_PREFIX%%'`, config.apiPrefix); html = html.replace(`'%%MASTRA_HIDE_CLOUD_CTA%%'`, config.hideCloudCta); html = html.replace(`'%%MASTRA_CLOUD_API_ENDPOINT%%'`, config.cloudApiEndpoint); html = html.replace(`'%%MASTRA_EXPERIMENTAL_FEATURES%%'`, config.experimentalFeatures); html = html.replace(`'%%MASTRA_TEMPLATES%%'`, config.templates); html = html.replace(`'%%MASTRA_TELEMETRY_DISABLED%%'`, config.telemetryDisabled); html = html.replace(`'%%MASTRA_REQUEST_CONTEXT_PRESETS%%'`, config.requestContextPresets); html = html.replace(`'%%MASTRA_EXPERIMENTAL_UI%%'`, config.experimentalUI); html = html.replace(`'%%MASTRA_AGENT_SIGNALS%%'`, config.agentSignals); if (config.autoDetectUrl) { html = html.replace(`'%%MASTRA_AUTO_DETECT_URL%%'`, config.autoDetectUrl); } html = html.replaceAll("%%MASTRA_STUDIO_BASE_PATH%%", config.basePath); return html; } function isBuiltinModule(specifier) { return module$1.builtinModules.includes(specifier) || specifier.startsWith("node:") || module$1.builtinModules.includes(specifier.replace(/^node:/, "")); } function isBareModuleSpecifier(specifier) { if (!specifier || specifier.startsWith("#")) { return false; } if (isRelativeImportSpecifier(specifier) || isAbsolutePathSpecifier(specifier)) { return false; } if (isBuiltinModule(specifier)) { return false; } if (isExternalProtocolImport(specifier)) { return false; } return true; } exports.detectRuntime = detectRuntime; exports.getCompiledDepCachePath = getCompiledDepCachePath; exports.getNodeResolveOptions = getNodeResolveOptions; exports.getPackageName = getPackageName; exports.injectStudioHtmlConfig = injectStudioHtmlConfig; exports.isBareModuleSpecifier = isBareModuleSpecifier; exports.isBuiltinModule = isBuiltinModule; exports.isDependencyPartOfPackage = isDependencyPartOfPackage; exports.isExternalProtocolImport = isExternalProtocolImport; exports.normalizeStudioBase = normalizeStudioBase; exports.rollupSafeName = rollupSafeName; exports.slash = slash; //# sourceMappingURL=chunk-3T7FP546.cjs.map //# sourceMappingURL=chunk-3T7FP546.cjs.map