#!/usr/bin/env node
import {
  init_esm_shims
} from "./chunk-DHET7RCE.js";

// node_modules/ink-testing-library/build/index.js
init_esm_shims();
import { EventEmitter } from "events";
import { render as inkRender } from "ink";
var Stdout = class extends EventEmitter {
  get columns() {
    return 100;
  }
  frames = [];
  _lastFrame;
  write = (frame) => {
    this.frames.push(frame);
    this._lastFrame = frame;
  };
  lastFrame = () => this._lastFrame;
};
var Stderr = class extends EventEmitter {
  frames = [];
  _lastFrame;
  write = (frame) => {
    this.frames.push(frame);
    this._lastFrame = frame;
  };
  lastFrame = () => this._lastFrame;
};
var Stdin = class extends EventEmitter {
  // eslint-disable-next-line @typescript-eslint/naming-convention
  isTTY = true;
  data = null;
  // eslint-disable-line @typescript-eslint/ban-types
  constructor(options = {}) {
    super();
    this.isTTY = options.isTTY ?? true;
  }
  write = (data) => {
    this.data = data;
    this.emit("readable");
    this.emit("data", data);
  };
  setEncoding() {
  }
  setRawMode() {
  }
  resume() {
  }
  pause() {
  }
  ref() {
  }
  unref() {
  }
  // eslint-disable-next-line @typescript-eslint/ban-types
  read = () => {
    const { data } = this;
    this.data = null;
    return data;
  };
};
var instances = [];
var render = (tree) => {
  const stdout = new Stdout();
  const stderr = new Stderr();
  const stdin = new Stdin();
  const instance = inkRender(tree, {
    // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
    stdout,
    // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
    stderr,
    // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
    stdin,
    debug: true,
    exitOnCtrlC: false,
    patchConsole: false
  });
  instances.push(instance);
  return {
    rerender: instance.rerender,
    unmount: instance.unmount,
    cleanup: instance.cleanup,
    stdout,
    stderr,
    stdin,
    frames: stdout.frames,
    lastFrame: stdout.lastFrame
  };
};

export {
  render
};
//# sourceMappingURL=chunk-66UDJBF6.js.map