"use strict";
/* Socket Lib - Built with esbuild */
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdout_exports = {};
__export(stdout_exports, {
  clearLine: () => clearLine,
  clearScreenDown: () => clearScreenDown,
  cursorTo: () => cursorTo,
  ensureCursorOnExit: () => ensureCursorOnExit,
  getColumns: () => getColumns,
  getRows: () => getRows,
  hideCursor: () => hideCursor,
  isTTY: () => isTTY,
  showCursor: () => showCursor,
  stdout: () => stdout,
  write: () => write,
  writeLine: () => writeLine
});
module.exports = __toCommonJS(stdout_exports);
var import_tty = require("tty");
const stdout = process.stdout;
function writeLine(text = "") {
  stdout.write(`${text}
`);
}
function write(text) {
  stdout.write(text);
}
function clearLine() {
  if (stdout.isTTY) {
    stdout.cursorTo(0);
    stdout.clearLine(0);
  }
}
function cursorTo(x, y) {
  if (stdout.isTTY) {
    stdout.cursorTo(x, y);
  }
}
function clearScreenDown() {
  if (stdout.isTTY) {
    stdout.clearScreenDown();
  }
}
function isTTY() {
  return stdout.isTTY || false;
}
function getColumns() {
  return stdout.columns || 80;
}
function getRows() {
  return stdout.rows || 24;
}
function hideCursor() {
  if (stdout.isTTY && stdout instanceof import_tty.WriteStream) {
    stdout.write("\x1B[?25l");
  }
}
function showCursor() {
  if (stdout.isTTY && stdout instanceof import_tty.WriteStream) {
    stdout.write("\x1B[?25h");
  }
}
function ensureCursorOnExit() {
  process.on("exit", showCursor);
  process.on("SIGINT", () => {
    showCursor();
    process.exit(130);
  });
  process.on("SIGTERM", () => {
    showCursor();
    process.exit(143);
  });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  clearLine,
  clearScreenDown,
  cursorTo,
  ensureCursorOnExit,
  getColumns,
  getRows,
  hideCursor,
  isTTY,
  showCursor,
  stdout,
  write,
  writeLine
});
