// src/testing/vitest.ts
import { fileURLToPath } from "node:url";
function here(relativeFromRoot) {
  return fileURLToPath(new URL(`../../${relativeFromRoot}`, import.meta.url));
}
function rangoTestAliases(opts = {}) {
  const aliases = [
    // Real impls (index.rsc.ts) for the bare specifier ONLY — exact regex so
    // subpaths (/testing, /client, /cache, ...) are untouched. React stays the
    // client build, so createContext and "use client" modules work.
    { find: /^@rangojs\/router$/, replacement: here("src/index.rsc.ts") },
    {
      find: "@rangojs/router:version",
      replacement: here("src/testing/vitest-stubs/version.ts")
    },
    {
      find: /^@vitejs\/plugin-rsc\/rsc$/,
      replacement: here("src/testing/vitest-stubs/plugin-rsc.ts")
    }
  ];
  if (opts.cloudflare) {
    aliases.push(
      {
        find: "cloudflare:workers",
        replacement: here("src/testing/vitest-stubs/cloudflare-workers.ts")
      },
      {
        find: "cloudflare:email",
        replacement: here("src/testing/vitest-stubs/cloudflare-email.ts")
      }
    );
  }
  return aliases;
}
var rangoInlineDeps = [/@rangojs[/\\]router/];
function rangoTestConfig(opts = {}) {
  return {
    alias: rangoTestAliases(opts),
    // fresh copy so the shared rangoInlineDeps const is never aliased into (or
    // mutated through) a consumer's resolved config
    server: { deps: { inline: [...rangoInlineDeps] } }
  };
}
export {
  rangoInlineDeps,
  rangoTestAliases,
  rangoTestConfig
};
