import {
  detectAutocompleteType,
  extractSlashQuery,
  extractResourceQuery,
  parseInput
} from "../utils/inputParsing.js";
class InputService {
  /**
   * Detects what type of autocomplete should be shown
   */
  detectAutocompleteType(input) {
    return detectAutocompleteType(input);
  }
  /**
   * Extracts slash command query
   */
  extractSlashQuery(input) {
    return extractSlashQuery(input);
  }
  /**
   * Extracts resource mention query
   */
  extractResourceQuery(input) {
    return extractResourceQuery(input);
  }
  /**
   * Parses input
   */
  parseInput(input) {
    return parseInput(input);
  }
  /**
   * Deletes word backward from cursor position
   */
  deleteWordBackward(text, cursorPos = text.length) {
    if (cursorPos === 0) return text;
    let pos = cursorPos - 1;
    while (pos >= 0) {
      const char = text[pos];
      if (char && !/\s/.test(char)) break;
      pos--;
    }
    while (pos >= 0) {
      const char = text[pos];
      if (char && /\s/.test(char)) break;
      pos--;
    }
    const deleteStart = pos + 1;
    return text.slice(0, deleteStart) + text.slice(cursorPos);
  }
  /**
   * Deletes word forward from cursor position
   */
  deleteWordForward(text, cursorPos = text.length) {
    if (cursorPos >= text.length) return text;
    let pos = cursorPos;
    while (pos < text.length) {
      const char = text[pos];
      if (char && !/\s/.test(char)) break;
      pos++;
    }
    while (pos < text.length) {
      const char = text[pos];
      if (char && /\s/.test(char)) break;
      pos++;
    }
    return text.slice(0, cursorPos) + text.slice(pos);
  }
  /**
   * Deletes entire line (for single-line input)
   */
  deleteLine(_text) {
    return "";
  }
}
export {
  InputService
};
