import { createRequire as __banner_cjsRequire } from "module"; const require = __banner_cjsRequire(import.meta.url);

// src/shared/git-types.ts
function createGitProxy(endpoint, fetchFn, defaultPayload) {
  return new Proxy({}, {
    get(_target, command) {
      return async (options) => {
        const res = await fetchFn(endpoint, {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({
            ...defaultPayload,
            command,
            options: options || {}
          })
        });
        const envelope = await res.json();
        if (!envelope.ok) throw new Error(envelope.error ?? "Unknown error");
        return envelope.data;
      };
    }
  });
}
function createSimpleGitProxy(endpoint, fetchFn, defaultPayload) {
  return new Proxy({}, {
    get(_target, command) {
      return async (options) => {
        const res = await fetchFn(endpoint, {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({
            ...defaultPayload,
            command,
            options: options ?? {}
          })
        });
        const envelope = await res.json();
        if (!envelope.ok) throw new Error(envelope.error ?? "Unknown error");
        return envelope.data;
      };
    }
  });
}
export {
  createGitProxy,
  createSimpleGitProxy
};
