/**
 * Dynamic import wrapper for optional peer dependencies.
 *
 * Uses Function constructor to create a dynamic import that no bundler
 * (Webpack, Turbopack, Vite) can statically analyze. This prevents
 * build errors when the optional package is not installed, while still
 * allowing runtime resolution when it is available.
 *
 * Security note: The Function constructor is used here intentionally to
 * hide import() calls from bundler static analysis. The module_name
 * parameter is always a hardcoded package name (e.g. 'hazo_pdf'),
 * never user input — this is safe from code injection.
 *
 * If Function-based import fails (e.g. strict CSP), falls back to
 * variable-indirection import with webpackIgnore hint.
 */
export function optional_import(module_name) {
    try {
        // Function constructor hides the import() call from all bundlers' static analysis.
        // Neither Webpack nor Turbopack can trace into Function() bodies.
        // The module_name is always a hardcoded package name, never user input.
        // eslint-disable-next-line no-new-func
        const dynamic_import = new Function('m', 'return import(m)');
        return dynamic_import(module_name);
    }
    catch {
        // Fallback: variable indirection (works in Node.js, Webpack with webpackIgnore)
        const name = module_name;
        return import(/* webpackIgnore: true */ name);
    }
}
//# sourceMappingURL=optional_import.js.map