import { createMockApp } from '../chunk-BRVIXGUW.mjs';
import '../chunk-AMZXALF6.mjs';
import '../chunk-3G6RQLXK.mjs';

// src/mock/msw.ts
async function createMswHandlers(options = {}) {
  const baseUrl = options.baseUrl ?? "http://localhost:8787";
  const handle = createMockApp(options);
  const msw = await import('msw').catch(() => {
    throw new Error("msw is required to use @cimplify/sdk/mock/msw \u2014 install it as a peer dependency");
  });
  const proxy = async ({ request }) => {
    const url = new URL(request.url);
    const path = url.pathname + url.search;
    const init = {
      method: request.method,
      headers: request.headers,
      body: ["GET", "HEAD"].includes(request.method) ? void 0 : await request.text()
    };
    return handle.request(path, init);
  };
  const apiBase = baseUrl.replace(/\/$/, "");
  const handlers = [
    msw.http.all(`${apiBase}/api/v1/*`, proxy),
    msw.http.all(`${apiBase}/_mock/*`, proxy),
    msw.http.get(`${apiBase}/healthz`, proxy)
  ];
  return {
    handlers,
    deps: handle.deps,
    baseUrl,
    reset: () => handle.deps.resetAll()
  };
}

// src/testing/msw-adapter.ts
async function createMswHandlers2(options = {}) {
  return createMswHandlers(options);
}

export { createMswHandlers2 as createMswHandlers };
