import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  ProjectModelProvider
} from "./chunk-XJE267QM.js";
import {
  PanoramaProvider
} from "./chunk-YTGCPERW.js";
import {
  addUserFields
} from "./chunk-V2542KTT.js";
import {
  AuthProvider,
  BiProvider,
  DebugLogProvider,
  ErrorReporterProvider,
  isLoggedInToAccount
} from "./chunk-VZ3FZHJK.js";
import {
  createRendererToString
} from "./chunk-2DKXIL7C.js";
import {
  require_react
} from "./chunk-7ZOEVDW3.js";
import {
  getDebugLogFilePath
} from "./chunk-XTVDTH5G.js";
import {
  CliError,
  CliErrorCode
} from "./chunk-PIOT47FJ.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-astro-commands/src/non-interactive/logger.ts
init_esm_shims();
function log(message) {
  console.log(message);
}

// ../cli-astro-commands/src/non-interactive/execute-command.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
async function executeCommand(services, model, renderFn) {
  const authData = await isLoggedInToAccount();
  if (!authData) {
    throw new CliError({
      code: CliErrorCode.AuthenticationRequired(),
      cause: null
    });
  }
  services.errorReporter.setUser({ id: authData.userInfo.userId });
  addUserFields(services.biLogger, authData.userInfo.userId);
  const renderer = createRendererToString({ stripAnsi: false });
  const debugLogFilePath = getDebugLogFilePath(model.projectFolder);
  return new Promise((resolve, reject) => {
    renderer.render(
      /* @__PURE__ */ import_react.default.createElement(BiProvider, { value: services.biLogger }, /* @__PURE__ */ import_react.default.createElement(ErrorReporterProvider, { value: services.errorReporter }, /* @__PURE__ */ import_react.default.createElement(PanoramaProvider, { value: services.panorama }, /* @__PURE__ */ import_react.default.createElement(AuthProvider, null, /* @__PURE__ */ import_react.default.createElement(DebugLogProvider, { filePath: debugLogFilePath }, /* @__PURE__ */ import_react.default.createElement(ProjectModelProvider, { value: model }, renderFn((...args) => {
        renderer.unmount();
        resolve(...args);
      })))))))
    );
    renderer.waitUntilExit().catch(reject);
  });
}

export {
  log,
  executeCommand
};
//# sourceMappingURL=chunk-XUXZFTF6.js.map