"use strict";
/* Socket Lib - Built with esbuild */
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
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_node_process = __toESM(require("node:process"));
var import_node_tty = require("node:tty");
var import_internal = require("./_internal");
const stdout = import_node_process.default.stdout;
let _cursorExitRegistered = false;
function clearLine() {
  (0, import_internal.clearLineOn)(stdout);
}
function clearScreenDown() {
  if (stdout.isTTY) {
    stdout.clearScreenDown();
  }
}
function cursorTo(x, y) {
  (0, import_internal.cursorToOn)(stdout, x, y);
}
function ensureCursorOnExit() {
  if (_cursorExitRegistered) {
    return;
  }
  _cursorExitRegistered = true;
  import_node_process.default.on("exit", showCursor);
  import_node_process.default.on("SIGINT", () => {
    showCursor();
    import_node_process.default.exit(130);
  });
  import_node_process.default.on("SIGTERM", () => {
    showCursor();
    import_node_process.default.exit(143);
  });
}
function getColumns() {
  return (0, import_internal.getColumnsOf)(stdout);
}
function getRows() {
  return (0, import_internal.getRowsOf)(stdout);
}
function hideCursor() {
  if (stdout.isTTY && stdout instanceof import_node_tty.WriteStream) {
    stdout.write("\x1B[?25l");
  }
}
function isTTY() {
  return (0, import_internal.isTTYOf)(stdout);
}
function showCursor() {
  if (stdout.isTTY && stdout instanceof import_node_tty.WriteStream) {
    stdout.write("\x1B[?25h");
  }
}
function write(text) {
  stdout.write(text);
}
function writeLine(text = "") {
  stdout.write(`${text}
`);
}
// 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
});
