"use strict";
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 CommandService_exports = {};
__export(CommandService_exports, {
  CommandService: () => CommandService,
  createSendMessageMarker: () => createSendMessageMarker,
  isSendMessageMarker: () => isSendMessageMarker,
  isStyledOutput: () => isStyledOutput
});
module.exports = __toCommonJS(CommandService_exports);
var import_inputParsing = require("../utils/inputParsing.js");
var import_commands = require("../interactive-commands/commands.js");
function isStyledOutput(result) {
  return typeof result === "object" && result !== null && "styledType" in result && "styledData" in result && "fallbackText" in result;
}
function createSendMessageMarker(text) {
  return { __sendMessage: true, text };
}
function isSendMessageMarker(result) {
  return typeof result === "object" && result !== null && "__sendMessage" in result && result.__sendMessage === true && "text" in result && typeof result.text === "string";
}
class CommandService {
  /**
   * Parses input and determines if it's a command or prompt
   */
  parseInput(input) {
    return (0, import_inputParsing.parseInput)(input);
  }
  /**
   * Executes a command and returns the result
   */
  async executeCommand(command, args, agent, sessionId, configFilePath) {
    const result = await (0, import_commands.executeCommand)(command, args, agent, sessionId, configFilePath);
    if (isSendMessageMarker(result)) {
      return { type: "sendMessage", messageToSend: result.text };
    }
    if (typeof result === "string") {
      return { type: "output", output: result };
    }
    if (isStyledOutput(result)) {
      return { type: "styled", styled: result };
    }
    return { type: "handled" };
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  CommandService,
  createSendMessageMarker,
  isSendMessageMarker,
  isStyledOutput
});
