import { InstrumentationConfig } from '@apm-js-collab/code-transformer';

interface BundlerPluginOptions {
    /**
     * Enable debug logging
     */
    debug?: boolean;
    /**
     * Additional instrumentation configs to apply
     */
    instrumentations?: InstrumentationConfig[];
    /**
     * Whether to bundle for browser environments.
     *
     * When true, uses 'dc-browser' for browser-compatible diagnostics_channel polyfill.
     * When false, uses Node.js built-in 'diagnostics_channel' and 'async_hooks'.
     * Defaults to true (assumes browser build).
     */
    browser?: boolean;
}

/**
 * Webpack loader for auto-instrumentation.
 *
 * This is a webpack loader (not a plugin) for compatibility with tools that only support loaders,
 * such as Next.js Turbopack. Unlike the other exports in this package, this does not use unplugin.
 *
 * Usage in next.config.js / next.config.ts:
 * ```javascript
 * export default {
 *   webpack(config) {
 *     config.module.rules.unshift({
 *       use: [{ loader: 'braintrust/webpack-loader' }],
 *     });
 *     return config;
 *   },
 * };
 * ```
 *
 * For browser builds, the loader automatically uses 'dc-browser' for diagnostics_channel polyfill.
 */

/**
 * Webpack loader that instruments JavaScript code using code-transformer.
 *
 * Accepts the same options as the webpack plugin (BundlerPluginOptions).
 */
declare function codeTransformerLoader(this: any, code: string, inputSourceMap?: any): void;
declare namespace codeTransformerLoader {
    type Options = BundlerPluginOptions;
}

export { codeTransformerLoader as default };
