// @bun
import {
  init_log,
  logError
} from "./chunk-8wsj9fff.js";
import {
  init_envUtils,
  isEnvTruthy
} from "./chunk-6k1rsk85.js";

// src/utils/renderOptions.ts
init_envUtils();
init_log();
import { openSync } from "fs";
import { ReadStream } from "tty";
var cachedStdinOverride = null;
function getStdinOverride() {
  if (cachedStdinOverride !== null) {
    return cachedStdinOverride;
  }
  if (process.stdin.isTTY) {
    cachedStdinOverride = undefined;
    return;
  }
  if (isEnvTruthy(process.env.CI)) {
    cachedStdinOverride = undefined;
    return;
  }
  if (process.argv.includes("mcp")) {
    cachedStdinOverride = undefined;
    return;
  }
  if (process.platform === "win32") {
    cachedStdinOverride = undefined;
    return;
  }
  try {
    const ttyFd = openSync("/dev/tty", "r");
    const ttyStream = new ReadStream(ttyFd);
    ttyStream.isTTY = true;
    cachedStdinOverride = ttyStream;
    return cachedStdinOverride;
  } catch (err) {
    logError(err);
    cachedStdinOverride = undefined;
    return;
  }
}
function getBaseRenderOptions(exitOnCtrlC = false) {
  const stdin = getStdinOverride();
  const options = { exitOnCtrlC };
  if (stdin) {
    options.stdin = stdin;
  }
  return options;
}

export { getBaseRenderOptions };

//# debugId=ECDEEF7BD919FD3164756E2164756E21
//# sourceMappingURL=chunk-gdt28rhq.js.map
