"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/auto-instrumentations/bundler/esbuild.ts
var esbuild_exports = {};
__export(esbuild_exports, {
  esbuildPlugin: () => esbuildPlugin
});
module.exports = __toCommonJS(esbuild_exports);

// src/auto-instrumentations/bundler/plugin.ts
var import_unplugin = require("unplugin");
var import_code_transformer = require("@apm-js-collab/code-transformer");
var import_path = require("path");
var import_fs = require("fs");
var import_url = require("url");
var import_module_details_from_path = __toESM(require("module-details-from-path"));

// src/isomorph.ts
var DefaultAsyncLocalStorage = class {
  constructor() {
  }
  enterWith(_) {
  }
  run(_, callback) {
    return callback();
  }
  getStore() {
    return void 0;
  }
};
var DefaultChannel = class {
  constructor(name) {
    this.name = name;
  }
  hasSubscribers = false;
  subscribe(_subscription) {
  }
  unsubscribe(_subscription) {
    return false;
  }
  bindStore(_store, _transform) {
  }
  unbindStore(_store) {
    return false;
  }
  publish(_message) {
  }
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  runStores(_message, fn, thisArg, ...args) {
    return fn.apply(thisArg, args);
  }
};
var DefaultTracingChannel = class {
  start;
  end;
  asyncStart;
  asyncEnd;
  error;
  constructor(nameOrChannels) {
    if (typeof nameOrChannels === "string") {
      this.start = new DefaultChannel(`tracing:${nameOrChannels}:start`);
      this.end = new DefaultChannel(`tracing:${nameOrChannels}:end`);
      this.asyncStart = new DefaultChannel(
        `tracing:${nameOrChannels}:asyncStart`
      );
      this.asyncEnd = new DefaultChannel(`tracing:${nameOrChannels}:asyncEnd`);
      this.error = new DefaultChannel(`tracing:${nameOrChannels}:error`);
      return;
    }
    this.start = nameOrChannels.start ?? new DefaultChannel("tracing:start");
    this.end = nameOrChannels.end ?? new DefaultChannel("tracing:end");
    this.asyncStart = nameOrChannels.asyncStart ?? new DefaultChannel("tracing:asyncStart");
    this.asyncEnd = nameOrChannels.asyncEnd ?? new DefaultChannel("tracing:asyncEnd");
    this.error = nameOrChannels.error ?? new DefaultChannel("tracing:error");
  }
  get hasSubscribers() {
    return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers || this.asyncEnd.hasSubscribers || this.error.hasSubscribers;
  }
  subscribe(_handlers) {
  }
  unsubscribe(_handlers) {
    return false;
  }
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  traceSync(fn, _message, thisArg, ...args) {
    return fn.apply(thisArg, args);
  }
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  tracePromise(fn, _message, thisArg, ...args) {
    return Promise.resolve(fn.apply(thisArg, args));
  }
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  traceCallback(fn, _position, _message, thisArg, ...args) {
    return fn.apply(thisArg, args);
  }
};
var iso = {
  buildType: "unknown",
  // Will be set by configureBrowser() or configureNode()
  getRepoInfo: async (_settings) => void 0,
  getPastNAncestors: async () => [],
  getEnv: (_name) => void 0,
  getCallerLocation: () => void 0,
  newAsyncLocalStorage: () => new DefaultAsyncLocalStorage(),
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  newTracingChannel: (nameOrChannels) => new DefaultTracingChannel(nameOrChannels),
  processOn: (_0, _1) => {
  },
  basename: (filepath) => filepath.split(/[\\/]/).pop() || filepath,
  writeln: (text) => console.log(text)
};
var isomorph_default = iso;

// src/instrumentation/core/channel-definitions.ts
function channel(spec) {
  return spec;
}
function defineChannels(pkg, channels) {
  return Object.fromEntries(
    Object.entries(channels).map(([key, spec]) => {
      const fullChannelName = `orchestrion:${pkg}:${spec.channelName}`;
      if (spec.kind === "async") {
        const asyncSpec = spec;
        const tracingChannel2 = () => isomorph_default.newTracingChannel(
          fullChannelName
        );
        return [
          key,
          {
            ...asyncSpec,
            tracingChannel: tracingChannel2,
            tracePromise: (fn, context) => tracingChannel2().tracePromise(
              fn,
              // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
              context
            )
          }
        ];
      }
      const syncSpec = spec;
      const tracingChannel = () => isomorph_default.newTracingChannel(
        fullChannelName
      );
      return [
        key,
        {
          ...syncSpec,
          tracingChannel,
          traceSync: (fn, context) => tracingChannel().traceSync(
            fn,
            // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
            context
          )
        }
      ];
    })
  );
}

// src/instrumentation/plugins/openai-channels.ts
var openAIChannels = defineChannels("openai", {
  chatCompletionsCreate: channel({
    channelName: "chat.completions.create",
    kind: "async"
  }),
  embeddingsCreate: channel({
    channelName: "embeddings.create",
    kind: "async"
  }),
  betaChatCompletionsParse: channel({
    channelName: "beta.chat.completions.parse",
    kind: "async"
  }),
  betaChatCompletionsStream: channel({
    channelName: "beta.chat.completions.stream",
    kind: "sync-stream"
  }),
  moderationsCreate: channel({
    channelName: "moderations.create",
    kind: "async"
  }),
  responsesCreate: channel({
    channelName: "responses.create",
    kind: "async"
  }),
  responsesStream: channel({
    channelName: "responses.stream",
    kind: "sync-stream"
  }),
  responsesParse: channel({
    channelName: "responses.parse",
    kind: "async"
  })
});

// src/auto-instrumentations/configs/openai.ts
var openaiConfigs = [
  // Chat Completions
  {
    channelName: openAIChannels.chatCompletionsCreate.channelName,
    module: {
      name: "openai",
      versionRange: ">=4.0.0 <5.0.0",
      filePath: "resources/chat/completions.mjs"
    },
    functionQuery: {
      className: "Completions",
      methodName: "create",
      kind: "Async"
    }
  },
  {
    channelName: openAIChannels.chatCompletionsCreate.channelName,
    module: {
      name: "openai",
      versionRange: ">=4.0.0 <5.0.0",
      filePath: "resources/chat/completions/completions.mjs"
    },
    functionQuery: {
      className: "Completions",
      methodName: "create",
      kind: "Async"
    }
  },
  {
    channelName: openAIChannels.chatCompletionsCreate.channelName,
    module: {
      name: "openai",
      versionRange: ">=5.0.0",
      filePath: "resources/chat/completions/completions.mjs"
    },
    functionQuery: {
      className: "Completions",
      methodName: "create",
      kind: "Async"
    }
  },
  // Embeddings
  {
    channelName: openAIChannels.embeddingsCreate.channelName,
    module: {
      name: "openai",
      versionRange: ">=4.0.0",
      filePath: "resources/embeddings.mjs"
    },
    functionQuery: {
      className: "Embeddings",
      methodName: "create",
      kind: "Async"
    }
  },
  // Beta Chat Completions Parse
  {
    channelName: openAIChannels.betaChatCompletionsParse.channelName,
    module: {
      name: "openai",
      versionRange: ">=4.0.0 <5.0.0",
      filePath: "resources/beta/chat/completions.mjs"
    },
    functionQuery: {
      className: "Completions",
      methodName: "parse",
      kind: "Async"
    }
  },
  {
    channelName: openAIChannels.betaChatCompletionsParse.channelName,
    module: {
      name: "openai",
      versionRange: ">=5.0.0",
      filePath: "resources/chat/completions/completions.mjs"
    },
    functionQuery: {
      className: "Completions",
      methodName: "parse",
      kind: "Async"
    }
  },
  // Moderations
  {
    channelName: openAIChannels.moderationsCreate.channelName,
    module: {
      name: "openai",
      versionRange: ">=4.0.0",
      filePath: "resources/moderations.mjs"
    },
    functionQuery: {
      className: "Moderations",
      methodName: "create",
      kind: "Async"
    }
  },
  // Beta Chat Completions Stream
  {
    channelName: openAIChannels.betaChatCompletionsStream.channelName,
    module: {
      name: "openai",
      versionRange: ">=4.0.0 <5.0.0",
      filePath: "resources/beta/chat/completions.mjs"
    },
    functionQuery: {
      className: "Completions",
      methodName: "stream",
      kind: "Sync"
    }
  },
  {
    channelName: openAIChannels.betaChatCompletionsStream.channelName,
    module: {
      name: "openai",
      versionRange: ">=5.0.0",
      filePath: "resources/chat/completions/completions.mjs"
    },
    functionQuery: {
      className: "Completions",
      methodName: "stream",
      kind: "Sync"
    }
  },
  // Responses API (v4.87.0+)
  {
    channelName: openAIChannels.responsesCreate.channelName,
    module: {
      name: "openai",
      versionRange: ">=4.87.0",
      filePath: "resources/responses/responses.mjs"
    },
    functionQuery: {
      className: "Responses",
      methodName: "create",
      kind: "Async"
    }
  },
  {
    channelName: openAIChannels.responsesStream.channelName,
    module: {
      name: "openai",
      versionRange: ">=4.87.0",
      filePath: "resources/responses/responses.mjs"
    },
    functionQuery: {
      className: "Responses",
      methodName: "stream",
      kind: "Sync"
    }
  },
  {
    channelName: openAIChannels.responsesParse.channelName,
    module: {
      name: "openai",
      versionRange: ">=4.87.0",
      filePath: "resources/responses/responses.mjs"
    },
    functionQuery: {
      className: "Responses",
      methodName: "parse",
      kind: "Async"
    }
  }
];

// src/instrumentation/plugins/anthropic-channels.ts
var anthropicChannels = defineChannels("@anthropic-ai/sdk", {
  messagesCreate: channel({
    channelName: "messages.create",
    kind: "async"
  }),
  betaMessagesCreate: channel({
    channelName: "beta.messages.create",
    kind: "async"
  })
});

// src/auto-instrumentations/configs/anthropic.ts
var anthropicConfigs = [
  // Messages API - create (supports streaming via stream=true parameter)
  {
    channelName: anthropicChannels.messagesCreate.channelName,
    module: {
      name: "@anthropic-ai/sdk",
      versionRange: ">=0.60.0",
      filePath: "resources/messages/messages.mjs"
    },
    functionQuery: {
      className: "Messages",
      methodName: "create",
      kind: "Async"
    }
  },
  // Beta Messages API - create (supports streaming via stream=true parameter)
  {
    channelName: anthropicChannels.betaMessagesCreate.channelName,
    module: {
      name: "@anthropic-ai/sdk",
      versionRange: ">=0.60.0",
      filePath: "resources/beta/messages/messages.mjs"
    },
    functionQuery: {
      className: "Messages",
      methodName: "create",
      kind: "Async"
    }
  }
];

// src/instrumentation/plugins/ai-sdk-channels.ts
var aiSDKChannels = defineChannels("ai", {
  generateText: channel({
    channelName: "generateText",
    kind: "async"
  }),
  streamText: channel({
    channelName: "streamText",
    kind: "async"
  }),
  streamTextSync: channel({
    channelName: "streamText.sync",
    kind: "sync-stream"
  }),
  generateObject: channel({
    channelName: "generateObject",
    kind: "async"
  }),
  streamObject: channel({
    channelName: "streamObject",
    kind: "async"
  }),
  streamObjectSync: channel({
    channelName: "streamObject.sync",
    kind: "sync-stream"
  }),
  agentGenerate: channel({
    channelName: "Agent.generate",
    kind: "async"
  }),
  agentStream: channel({
    channelName: "Agent.stream",
    kind: "async"
  }),
  toolLoopAgentGenerate: channel({
    channelName: "ToolLoopAgent.generate",
    kind: "async"
  }),
  toolLoopAgentStream: channel({
    channelName: "ToolLoopAgent.stream",
    kind: "async"
  })
});

// src/auto-instrumentations/configs/ai-sdk.ts
var aiSDKConfigs = [
  // generateText - async function
  {
    channelName: aiSDKChannels.generateText.channelName,
    module: {
      name: "ai",
      versionRange: ">=3.0.0",
      filePath: "dist/index.mjs"
    },
    functionQuery: {
      functionName: "generateText",
      kind: "Async"
    }
  },
  {
    channelName: aiSDKChannels.generateText.channelName,
    module: {
      name: "ai",
      versionRange: ">=3.0.0",
      filePath: "dist/index.js"
    },
    functionQuery: {
      functionName: "generateText",
      kind: "Async"
    }
  },
  // streamText - async function
  {
    channelName: aiSDKChannels.streamText.channelName,
    module: {
      name: "ai",
      versionRange: ">=3.0.0",
      filePath: "dist/index.mjs"
    },
    functionQuery: {
      functionName: "streamText",
      kind: "Async"
    }
  },
  {
    channelName: aiSDKChannels.streamTextSync.channelName,
    module: {
      name: "ai",
      versionRange: ">=3.0.0",
      filePath: "dist/index.js"
    },
    functionQuery: {
      functionName: "streamText",
      kind: "Sync"
    }
  },
  // generateObject - async function
  {
    channelName: aiSDKChannels.generateObject.channelName,
    module: {
      name: "ai",
      versionRange: ">=3.0.0",
      filePath: "dist/index.mjs"
    },
    functionQuery: {
      functionName: "generateObject",
      kind: "Async"
    }
  },
  {
    channelName: aiSDKChannels.generateObject.channelName,
    module: {
      name: "ai",
      versionRange: ">=3.0.0",
      filePath: "dist/index.js"
    },
    functionQuery: {
      functionName: "generateObject",
      kind: "Async"
    }
  },
  // streamObject - async function
  {
    channelName: aiSDKChannels.streamObject.channelName,
    module: {
      name: "ai",
      versionRange: ">=3.0.0",
      filePath: "dist/index.mjs"
    },
    functionQuery: {
      functionName: "streamObject",
      kind: "Async"
    }
  },
  {
    channelName: aiSDKChannels.streamObjectSync.channelName,
    module: {
      name: "ai",
      versionRange: ">=3.0.0",
      filePath: "dist/index.js"
    },
    functionQuery: {
      functionName: "streamObject",
      kind: "Sync"
    }
  },
  // Agent.generate - async method (v5 only)
  // The compiled AI SDK bundle emits this as an anonymous class method, so we
  // target the first async `generate` method in the file instead of a class name.
  {
    channelName: aiSDKChannels.agentGenerate.channelName,
    module: {
      name: "ai",
      versionRange: ">=5.0.0 <6.0.0",
      filePath: "dist/index.mjs"
    },
    functionQuery: {
      methodName: "generate",
      kind: "Async",
      index: 0
    }
  },
  {
    channelName: aiSDKChannels.agentGenerate.channelName,
    module: {
      name: "ai",
      versionRange: ">=5.0.0 <6.0.0",
      filePath: "dist/index.js"
    },
    functionQuery: {
      methodName: "generate",
      kind: "Async",
      index: 0
    }
  },
  // Agent.stream - async method (v5 only)
  // The compiled AI SDK bundle emits this as an anonymous class method, so we
  // target the first async `stream` method in the file instead of a class name.
  {
    channelName: aiSDKChannels.agentStream.channelName,
    module: {
      name: "ai",
      versionRange: ">=5.0.0 <6.0.0",
      filePath: "dist/index.mjs"
    },
    functionQuery: {
      methodName: "stream",
      kind: "Async",
      index: 0
    }
  },
  {
    channelName: aiSDKChannels.agentStream.channelName,
    module: {
      name: "ai",
      versionRange: ">=5.0.0 <6.0.0",
      filePath: "dist/index.js"
    },
    functionQuery: {
      methodName: "stream",
      kind: "Async",
      index: 0
    }
  },
  // ToolLoopAgent.generate - async method (v6 only, Experimental_Agent is an alias)
  // The compiled AI SDK bundle emits this as an anonymous class method, so we
  // target the first async `generate` method in the file instead of a class name.
  {
    channelName: aiSDKChannels.toolLoopAgentGenerate.channelName,
    module: {
      name: "ai",
      versionRange: ">=6.0.0 <7.0.0",
      filePath: "dist/index.mjs"
    },
    functionQuery: {
      methodName: "generate",
      kind: "Async",
      index: 0
    }
  },
  {
    channelName: aiSDKChannels.toolLoopAgentGenerate.channelName,
    module: {
      name: "ai",
      versionRange: ">=6.0.0 <7.0.0",
      filePath: "dist/index.js"
    },
    functionQuery: {
      methodName: "generate",
      kind: "Async",
      index: 0
    }
  },
  // ToolLoopAgent.stream - async method (v6 only, Experimental_Agent is an alias)
  // The compiled AI SDK bundle emits this as an anonymous class method, so we
  // target the first async `stream` method in the file instead of a class name.
  {
    channelName: aiSDKChannels.toolLoopAgentStream.channelName,
    module: {
      name: "ai",
      versionRange: ">=6.0.0 <7.0.0",
      filePath: "dist/index.mjs"
    },
    functionQuery: {
      methodName: "stream",
      kind: "Async",
      index: 0
    }
  },
  {
    channelName: aiSDKChannels.toolLoopAgentStream.channelName,
    module: {
      name: "ai",
      versionRange: ">=6.0.0 <7.0.0",
      filePath: "dist/index.js"
    },
    functionQuery: {
      methodName: "stream",
      kind: "Async",
      index: 0
    }
  }
];

// src/instrumentation/plugins/claude-agent-sdk-channels.ts
var claudeAgentSDKChannels = defineChannels(
  "@anthropic-ai/claude-agent-sdk",
  {
    query: channel({
      channelName: "query",
      kind: "async"
    })
  }
);

// src/auto-instrumentations/configs/claude-agent-sdk.ts
var claudeAgentSDKConfigs = [
  // query - Main entry point for agent interactions (top-level exported async generator function)
  {
    channelName: claudeAgentSDKChannels.query.channelName,
    module: {
      name: "@anthropic-ai/claude-agent-sdk",
      versionRange: ">=0.1.0",
      filePath: "sdk.mjs"
    },
    functionQuery: {
      functionName: "query",
      kind: "Async"
    }
  }
];

// src/instrumentation/plugins/google-genai-channels.ts
var googleGenAIChannels = defineChannels("@google/genai", {
  generateContent: channel({
    channelName: "models.generateContent",
    kind: "async"
  }),
  generateContentStream: channel({
    channelName: "models.generateContentStream",
    kind: "async"
  })
});

// src/auto-instrumentations/configs/google-genai.ts
var googleGenAIConfigs = [
  // Models.generateContentInternal - The actual class method (Node.js entry point)
  // Note: generateContent is an arrow function property that calls this internal method
  {
    channelName: googleGenAIChannels.generateContent.channelName,
    module: {
      name: "@google/genai",
      versionRange: ">=1.0.0",
      filePath: "dist/node/index.mjs"
    },
    functionQuery: {
      className: "Models",
      methodName: "generateContentInternal",
      kind: "Async"
    }
  },
  // Models.generateContentStreamInternal - The actual class method (Node.js entry point)
  // Note: generateContentStream is an arrow function property that calls this internal method
  {
    channelName: googleGenAIChannels.generateContentStream.channelName,
    module: {
      name: "@google/genai",
      versionRange: ">=1.0.0",
      filePath: "dist/node/index.mjs"
    },
    functionQuery: {
      className: "Models",
      methodName: "generateContentStreamInternal",
      kind: "Async"
    }
  }
];

// src/instrumentation/plugins/openrouter-channels.ts
var openRouterChannels = defineChannels("@openrouter/sdk", {
  chatSend: channel({
    channelName: "chat.send",
    kind: "async"
  }),
  embeddingsGenerate: channel({
    channelName: "embeddings.generate",
    kind: "async"
  }),
  betaResponsesSend: channel({
    channelName: "beta.responses.send",
    kind: "async"
  }),
  callModel: channel({
    channelName: "callModel",
    kind: "sync-stream"
  }),
  toolExecute: channel({
    channelName: "tool.execute",
    kind: "async"
  })
});

// src/auto-instrumentations/configs/openrouter.ts
var openRouterConfigs = [
  {
    channelName: openRouterChannels.chatSend.channelName,
    module: {
      name: "@openrouter/sdk",
      versionRange: ">=0.9.11 <1.0.0",
      filePath: "esm/sdk/chat.js"
    },
    functionQuery: {
      className: "Chat",
      methodName: "send",
      kind: "Async"
    }
  },
  {
    channelName: openRouterChannels.embeddingsGenerate.channelName,
    module: {
      name: "@openrouter/sdk",
      versionRange: ">=0.9.11 <1.0.0",
      filePath: "esm/sdk/embeddings.js"
    },
    functionQuery: {
      className: "Embeddings",
      methodName: "generate",
      kind: "Async"
    }
  },
  {
    channelName: openRouterChannels.betaResponsesSend.channelName,
    module: {
      name: "@openrouter/sdk",
      versionRange: ">=0.9.11 <1.0.0",
      filePath: "esm/sdk/responses.js"
    },
    functionQuery: {
      className: "Responses",
      methodName: "send",
      kind: "Async"
    }
  },
  {
    channelName: openRouterChannels.callModel.channelName,
    module: {
      name: "@openrouter/sdk",
      versionRange: ">=0.9.11 <1.0.0",
      filePath: "esm/sdk/sdk.js"
    },
    functionQuery: {
      className: "OpenRouter",
      methodName: "callModel",
      kind: "Sync"
    }
  }
];

// src/auto-instrumentations/bundler/plugin.ts
function getModuleVersion(basedir) {
  try {
    const packageJsonPath = (0, import_path.join)(basedir, "package.json");
    const packageJson = JSON.parse((0, import_fs.readFileSync)(packageJsonPath, "utf8"));
    if (packageJson.version) {
      return packageJson.version;
    }
  } catch (error) {
  }
  return void 0;
}
var unplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
  const allInstrumentations = [
    ...openaiConfigs,
    ...anthropicConfigs,
    ...aiSDKConfigs,
    ...claudeAgentSDKConfigs,
    ...googleGenAIConfigs,
    ...openRouterConfigs,
    ...options.instrumentations || []
  ];
  const dcModule = options.browser === false ? void 0 : "dc-browser";
  const instrumentationMatcher = (0, import_code_transformer.create)(allInstrumentations, dcModule);
  return {
    name: "code-transformer",
    enforce: "pre",
    transform(code, id) {
      const filePath = id.startsWith("file:") ? (0, import_url.fileURLToPath)(id) : id;
      const ext = (0, import_path.extname)(filePath);
      let isModule = ext === ".mjs" || ext === ".ts" || ext === ".tsx";
      if (ext === ".js") {
        isModule = code.includes("export ") || code.includes("import ");
      }
      const normalizedForPlatform = filePath.split("/").join(import_path.sep);
      const moduleDetails = (0, import_module_details_from_path.default)(normalizedForPlatform);
      if (!moduleDetails) {
        return null;
      }
      const moduleName = moduleDetails.name;
      const moduleVersion = getModuleVersion(moduleDetails.basedir);
      if (!moduleVersion) {
        console.warn(
          `No 'package.json' version found for module ${moduleName} at ${moduleDetails.basedir}. Skipping transformation.`
        );
        return null;
      }
      const normalizedModulePath = moduleDetails.path.replace(/\\/g, "/");
      const transformer = instrumentationMatcher.getTransformer(
        moduleName,
        moduleVersion,
        normalizedModulePath
      );
      if (!transformer) {
        return null;
      }
      try {
        const moduleType = isModule ? "esm" : "cjs";
        const result = transformer.transform(code, moduleType);
        return {
          code: result.code,
          map: result.map
        };
      } catch (error) {
        console.warn(`Code transformation failed for ${id}: ${error}`);
        return null;
      }
    }
  };
});

// src/auto-instrumentations/bundler/esbuild.ts
var esbuildPlugin = unplugin.esbuild;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  esbuildPlugin
});
