// Shim for */esm/_virtual/rolldown_runtime.mjs
// CF Workers bundle doesn't support createRequire(import.meta.url).
// We statically import modules that __require() needs and serve them.

import * as googleProtobuf from 'google-protobuf';
import * as googleProtobufAnyPb from 'google-protobuf/google/protobuf/any_pb';
import * as googleProtobufTimestampPb from 'google-protobuf/google/protobuf/timestamp_pb';
import _debugImport from 'debug';

const debugFactory = typeof _debugImport === 'function' ? _debugImport : (_debugImport as any).default || (() => () => {});

const _modules: Record<string, any> = {
  'google-protobuf': googleProtobuf,
  'google-protobuf/google/protobuf/any_pb': googleProtobufAnyPb,
  'google-protobuf/google/protobuf/timestamp_pb': googleProtobufTimestampPb,
  'debug': debugFactory,
};

const __commonJSMin = (cb: any, mod?: any) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);

const __require = (mod: string) => {
  if (_modules[mod]) return _modules[mod];
  if (typeof globalThis.require === 'function') {
    try { return globalThis.require(mod); } catch {}
  }
  console.warn('[rolldown-runtime] Cannot require:', mod);
  return {};
};

// Matches rolldown's __exportAll(gettersMap, symbols?) → frozen module object
const __defProp = Object.defineProperty;
const __exportAll = (all: Record<string, () => any>, symbols?: boolean) => {
  const target: any = {};
  for (const name in all) {
    __defProp(target, name, { get: all[name], enumerable: true });
  }
  if (symbols) {
    __defProp(target, Symbol.toStringTag, { value: 'Module' });
  }
  return target;
};

export { __commonJSMin, __require, __exportAll };
