import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  HttpClientProvider,
  buildHttpClientHeaders
} from "./chunk-JJWBWHWO.js";
import {
  PanoramaProvider,
  createCommandTransaction
} from "./chunk-YTGCPERW.js";
import {
  package_default,
  reportCommandStartEvent
} from "./chunk-EGTKQWHU.js";
import {
  BiProvider,
  ErrorReporterProvider
} from "./chunk-VZ3FZHJK.js";
import {
  render
} from "./chunk-2DKXIL7C.js";
import {
  require_react
} from "./chunk-7ZOEVDW3.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// src/commands/render-command.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
async function renderCommand(command, { biLogger, errorReporter, panorama }, tree) {
  await runCommand(command, { biLogger, errorReporter, panorama }, async () => {
    const headers = buildHttpClientHeaders({
      flow: "CLI",
      command: command.name(),
      cliVersion: package_default.version
    });
    await render(
      /* @__PURE__ */ import_react.default.createElement(BiProvider, { value: biLogger }, /* @__PURE__ */ import_react.default.createElement(ErrorReporterProvider, { value: errorReporter }, /* @__PURE__ */ import_react.default.createElement(PanoramaProvider, { value: panorama }, /* @__PURE__ */ import_react.default.createElement(HttpClientProvider, { headers }, tree))))
    );
  });
}
async function runCommand(command, services, commandFn) {
  const commandStatus = reportCommandStartEvent(services.biLogger, command);
  const transaction = createCommandTransaction(services.panorama, command);
  try {
    transaction.start();
    await commandFn();
    transaction.finish();
    commandStatus.succeed();
  } catch (e) {
    commandStatus.failed(e);
    throw e;
  }
}

export {
  renderCommand,
  runCommand
};
//# sourceMappingURL=chunk-EKGT7TUO.js.map