// src/registry.ts
var tokenizers = /* @__PURE__ */ new Map();
var profiles = /* @__PURE__ */ new Map();
var patternCache = /* @__PURE__ */ new Map();
function registerLanguage(code, tokenizer, profile) {
  tokenizers.set(code, tokenizer);
  profiles.set(code, profile);
  patternCache.delete(code);
}

// src/tokenizers/base.ts
var TokenStreamImpl = class {
  constructor(tokens, language) {
    this.pos = 0;
    this.tokens = tokens;
    this.language = language;
  }
  peek(offset = 0) {
    const index = this.pos + offset;
    if (index < 0 || index >= this.tokens.length) {
      return null;
    }
    return this.tokens[index];
  }
  advance() {
    if (this.isAtEnd()) {
      throw new Error("Unexpected end of token stream");
    }
    return this.tokens[this.pos++];
  }
  isAtEnd() {
    return this.pos >= this.tokens.length;
  }
  mark() {
    return { position: this.pos };
  }
  reset(mark) {
    this.pos = mark.position;
  }
  position() {
    return this.pos;
  }
  /**
   * Get remaining tokens as an array.
   */
  remaining() {
    return this.tokens.slice(this.pos);
  }
  /**
   * Consume tokens while predicate is true.
   */
  takeWhile(predicate) {
    const result = [];
    while (!this.isAtEnd() && predicate(this.peek())) {
      result.push(this.advance());
    }
    return result;
  }
  /**
   * Skip tokens while predicate is true.
   */
  skipWhile(predicate) {
    while (!this.isAtEnd() && predicate(this.peek())) {
      this.advance();
    }
  }
};
function createPosition(start, end) {
  return { start, end };
}
function createToken(value, kind, position, normalizedOrOptions) {
  if (typeof normalizedOrOptions === "string") {
    return { value, kind, position, normalized: normalizedOrOptions };
  }
  if (normalizedOrOptions) {
    const { normalized, stem, stemConfidence } = normalizedOrOptions;
    const token = { value, kind, position };
    if (normalized !== void 0) {
      token.normalized = normalized;
    }
    if (stem !== void 0) {
      token.stem = stem;
      if (stemConfidence !== void 0) {
        token.stemConfidence = stemConfidence;
      }
    }
    return token;
  }
  return { value, kind, position };
}
function isWhitespace(char) {
  return /\s/.test(char);
}
function isSelectorStart(char) {
  return char === "#" || char === "." || char === "[" || char === "@" || char === "*" || char === "<";
}
function isQuote(char) {
  return char === '"' || char === "'" || char === "`" || char === "\u300C" || char === "\u300D";
}
function isDigit(char) {
  return /\d/.test(char);
}
function isAsciiLetter(char) {
  return /[a-zA-Z]/.test(char);
}
function isAsciiIdentifierChar(char) {
  return /[a-zA-Z0-9_-]/.test(char);
}
function createLatinCharClassifiers(letterPattern) {
  const isLetter = (char) => letterPattern.test(char);
  const isIdentifierChar = (char) => isLetter(char) || /[0-9_-]/.test(char);
  return { isLetter, isIdentifierChar };
}
function extractCssSelector(input, startPos) {
  if (startPos >= input.length) return null;
  const char = input[startPos];
  if (!isSelectorStart(char)) return null;
  let pos = startPos;
  let selector = "";
  if (char === "#" || char === ".") {
    selector += input[pos++];
    while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
      selector += input[pos++];
    }
    if (selector.length <= 1) return null;
    if (pos < input.length && input[pos] === "." && char === "#") {
      const methodStart = pos + 1;
      let methodEnd = methodStart;
      while (methodEnd < input.length && isAsciiIdentifierChar(input[methodEnd])) {
        methodEnd++;
      }
      if (methodEnd < input.length && input[methodEnd] === "(") {
        return selector;
      }
    }
  } else if (char === "[") {
    let depth = 1;
    let inQuote = false;
    let quoteChar = null;
    let escaped = false;
    selector += input[pos++];
    while (pos < input.length && depth > 0) {
      const c = input[pos];
      selector += c;
      if (escaped) {
        escaped = false;
      } else if (c === "\\") {
        escaped = true;
      } else if (inQuote) {
        if (c === quoteChar) {
          inQuote = false;
          quoteChar = null;
        }
      } else {
        if (c === '"' || c === "'" || c === "`") {
          inQuote = true;
          quoteChar = c;
        } else if (c === "[") {
          depth++;
        } else if (c === "]") {
          depth--;
        }
      }
      pos++;
    }
    if (depth !== 0) return null;
  } else if (char === "@") {
    selector += input[pos++];
    while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
      selector += input[pos++];
    }
    if (selector.length <= 1) return null;
  } else if (char === "*") {
    selector += input[pos++];
    while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
      selector += input[pos++];
    }
    if (selector.length <= 1) return null;
  } else if (char === "<") {
    selector += input[pos++];
    if (pos >= input.length || !isAsciiLetter(input[pos])) return null;
    while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
      selector += input[pos++];
    }
    while (pos < input.length) {
      const modChar = input[pos];
      if (modChar === ".") {
        selector += input[pos++];
        if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {
          return null;
        }
        while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
          selector += input[pos++];
        }
      } else if (modChar === "#") {
        selector += input[pos++];
        if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {
          return null;
        }
        while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
          selector += input[pos++];
        }
      } else if (modChar === "[") {
        let depth = 1;
        let inQuote = false;
        let quoteChar = null;
        let escaped = false;
        selector += input[pos++];
        while (pos < input.length && depth > 0) {
          const c = input[pos];
          selector += c;
          if (escaped) {
            escaped = false;
          } else if (c === "\\") {
            escaped = true;
          } else if (inQuote) {
            if (c === quoteChar) {
              inQuote = false;
              quoteChar = null;
            }
          } else {
            if (c === '"' || c === "'" || c === "`") {
              inQuote = true;
              quoteChar = c;
            } else if (c === "[") {
              depth++;
            } else if (c === "]") {
              depth--;
            }
          }
          pos++;
        }
        if (depth !== 0) return null;
      } else {
        break;
      }
    }
    while (pos < input.length && isWhitespace(input[pos])) {
      selector += input[pos++];
    }
    if (pos < input.length && input[pos] === "/") {
      selector += input[pos++];
      while (pos < input.length && isWhitespace(input[pos])) {
        selector += input[pos++];
      }
    }
    if (pos >= input.length || input[pos] !== ">") return null;
    selector += input[pos++];
  }
  return selector || null;
}
function isPossessiveMarker(input, pos) {
  if (pos >= input.length || input[pos] !== "'") return false;
  if (pos + 1 >= input.length) return false;
  const nextChar = input[pos + 1].toLowerCase();
  if (nextChar !== "s") return false;
  if (pos + 2 >= input.length) return true;
  const afterS = input[pos + 2];
  return isWhitespace(afterS) || afterS === "*" || !isAsciiIdentifierChar(afterS);
}
function extractStringLiteral(input, startPos) {
  if (startPos >= input.length) return null;
  const openQuote = input[startPos];
  if (!isQuote(openQuote)) return null;
  if (openQuote === "'" && isPossessiveMarker(input, startPos)) {
    return null;
  }
  const closeQuoteMap = {
    '"': '"',
    "'": "'",
    "`": "`",
    "\u300C": "\u300D"
  };
  const closeQuote = closeQuoteMap[openQuote];
  if (!closeQuote) return null;
  let pos = startPos + 1;
  let literal = openQuote;
  let escaped = false;
  while (pos < input.length) {
    const char = input[pos];
    literal += char;
    if (escaped) {
      escaped = false;
    } else if (char === "\\") {
      escaped = true;
    } else if (char === closeQuote) {
      return literal;
    }
    pos++;
  }
  return literal;
}
function isUrlStart(input, pos) {
  if (pos >= input.length) return false;
  const char = input[pos];
  const next = input[pos + 1] || "";
  const third = input[pos + 2] || "";
  if (char === "/" && next !== "/" && /[a-zA-Z0-9._-]/.test(next)) {
    return true;
  }
  if (char === "/" && next === "/" && /[a-zA-Z]/.test(third)) {
    return true;
  }
  if (char === "." && (next === "/" || next === "." && third === "/")) {
    return true;
  }
  const slice = input.slice(pos, pos + 8).toLowerCase();
  if (slice.startsWith("http://") || slice.startsWith("https://")) {
    return true;
  }
  return false;
}
function extractUrl(input, startPos) {
  if (!isUrlStart(input, startPos)) return null;
  let pos = startPos;
  let url = "";
  const urlChars = /[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;
  while (pos < input.length) {
    const char = input[pos];
    if (char === "#") {
      if (url.length > 0 && /[a-zA-Z0-9/.]$/.test(url)) {
        url += char;
        pos++;
        while (pos < input.length && /[a-zA-Z0-9_-]/.test(input[pos])) {
          url += input[pos++];
        }
      }
      break;
    }
    if (urlChars.test(char)) {
      url += char;
      pos++;
    } else {
      break;
    }
  }
  if (url.length < 2) return null;
  return url;
}
function extractNumber(input, startPos) {
  if (startPos >= input.length) return null;
  const char = input[startPos];
  if (!isDigit(char) && char !== "-" && char !== "+") return null;
  let pos = startPos;
  let number = "";
  if (input[pos] === "-" || input[pos] === "+") {
    number += input[pos++];
  }
  if (pos >= input.length || !isDigit(input[pos])) {
    return null;
  }
  while (pos < input.length && isDigit(input[pos])) {
    number += input[pos++];
  }
  if (pos < input.length && input[pos] === ".") {
    number += input[pos++];
    while (pos < input.length && isDigit(input[pos])) {
      number += input[pos++];
    }
  }
  if (pos < input.length) {
    const suffix = input.slice(pos, pos + 2);
    if (suffix === "ms") {
      number += "ms";
    } else if (input[pos] === "s" || input[pos] === "m" || input[pos] === "h") {
      number += input[pos];
    }
  }
  return number;
}
var _BaseTokenizer = class _BaseTokenizer {
  constructor() {
    /** Keywords derived from profile, sorted longest-first for greedy matching */
    this.profileKeywords = [];
    /** Map for O(1) keyword lookups by lowercase native word */
    this.profileKeywordMap = /* @__PURE__ */ new Map();
  }
  /**
   * Initialize keyword mappings from a language profile.
   * Builds a list of native→english mappings from:
   * - profile.keywords (primary + alternatives)
   * - profile.references (me, it, you, etc.)
   * - profile.roleMarkers (into, from, with, etc.)
   *
   * Results are sorted longest-first for greedy matching (important for non-space languages).
   * Extras take precedence over profile entries when there are duplicates.
   *
   * @param profile - Language profile containing keyword translations
   * @param extras - Additional keyword entries to include (literals, positional, events)
   */
  initializeKeywordsFromProfile(profile, extras = []) {
    const keywordMap = /* @__PURE__ */ new Map();
    if (profile.keywords) {
      for (const [normalized, translation] of Object.entries(profile.keywords)) {
        keywordMap.set(translation.primary, {
          native: translation.primary,
          normalized: translation.normalized || normalized
        });
        if (translation.alternatives) {
          for (const alt of translation.alternatives) {
            keywordMap.set(alt, {
              native: alt,
              normalized: translation.normalized || normalized
            });
          }
        }
      }
    }
    if (profile.references) {
      for (const [normalized, native] of Object.entries(profile.references)) {
        keywordMap.set(native, { native, normalized });
      }
    }
    if (profile.roleMarkers) {
      for (const [role, marker] of Object.entries(profile.roleMarkers)) {
        if (marker.primary) {
          keywordMap.set(marker.primary, { native: marker.primary, normalized: role });
        }
        if (marker.alternatives) {
          for (const alt of marker.alternatives) {
            keywordMap.set(alt, { native: alt, normalized: role });
          }
        }
      }
    }
    for (const extra of extras) {
      keywordMap.set(extra.native, extra);
    }
    this.profileKeywords = Array.from(keywordMap.values()).sort(
      (a, b) => b.native.length - a.native.length
    );
    this.profileKeywordMap = /* @__PURE__ */ new Map();
    for (const keyword of this.profileKeywords) {
      this.profileKeywordMap.set(keyword.native.toLowerCase(), keyword);
      const normalized = this.removeDiacritics(keyword.native);
      if (normalized !== keyword.native && !this.profileKeywordMap.has(normalized.toLowerCase())) {
        this.profileKeywordMap.set(normalized.toLowerCase(), keyword);
      }
    }
  }
  /**
   * Remove diacritical marks from a word for normalization.
   * Primarily for Arabic (shadda, fatha, kasra, damma, sukun, etc.)
   * but could be extended for other languages.
   *
   * @param word - Word to normalize
   * @returns Word without diacritics
   */
  removeDiacritics(word) {
    return word.replace(/[\u064B-\u0652\u0670]/g, "");
  }
  /**
   * Try to match a keyword from profile at the current position.
   * Uses longest-first greedy matching (important for non-space languages).
   *
   * @param input - Input string
   * @param pos - Current position
   * @returns Token if matched, null otherwise
   */
  tryProfileKeyword(input, pos) {
    for (const entry of this.profileKeywords) {
      if (input.slice(pos).startsWith(entry.native)) {
        return createToken(
          entry.native,
          "keyword",
          createPosition(pos, pos + entry.native.length),
          entry.normalized
        );
      }
    }
    return null;
  }
  /**
   * Check if the remaining input starts with any known keyword.
   * Useful for non-space languages to detect word boundaries.
   *
   * @param input - Input string
   * @param pos - Current position
   * @returns true if a keyword starts at this position
   */
  isKeywordStart(input, pos) {
    const remaining = input.slice(pos);
    return this.profileKeywords.some((entry) => remaining.startsWith(entry.native));
  }
  /**
   * Look up a keyword by native word (case-insensitive).
   * O(1) lookup using the keyword map.
   *
   * @param native - Native word to look up
   * @returns KeywordEntry if found, undefined otherwise
   */
  lookupKeyword(native) {
    return this.profileKeywordMap.get(native.toLowerCase());
  }
  /**
   * Check if a word is a known keyword (case-insensitive).
   * O(1) lookup using the keyword map.
   *
   * @param native - Native word to check
   * @returns true if the word is a keyword
   */
  isKeyword(native) {
    return this.profileKeywordMap.has(native.toLowerCase());
  }
  /**
   * Set the morphological normalizer for this tokenizer.
   */
  setNormalizer(normalizer) {
    this.normalizer = normalizer;
  }
  /**
   * Try to normalize a word using the morphological normalizer.
   * Returns null if no normalizer is set or normalization fails.
   *
   * Note: We don't check isNormalizable() here because the individual tokenizers
   * historically called normalize() directly without that check. The normalize()
   * method itself handles returning noChange() for words that can't be normalized.
   */
  tryNormalize(word) {
    if (!this.normalizer) return null;
    const result = this.normalizer.normalize(word);
    if (result.stem !== word && result.confidence >= 0.7) {
      return result;
    }
    return null;
  }
  /**
   * Try morphological normalization and keyword lookup.
   *
   * If the word can be normalized to a stem that matches a known keyword,
   * returns a keyword token with morphological metadata (stem, stemConfidence).
   *
   * This is the common pattern for handling conjugated verbs across languages:
   * 1. Normalize the word (e.g., "toggled" → "toggle")
   * 2. Look up the stem in the keyword map
   * 3. Create a token with both the original form and stem metadata
   *
   * @param word - The word to normalize and look up
   * @param startPos - Start position for the token
   * @param endPos - End position for the token
   * @returns Token if stem matches a keyword, null otherwise
   */
  tryMorphKeywordMatch(word, startPos, endPos) {
    const result = this.tryNormalize(word);
    if (!result) return null;
    const stemEntry = this.lookupKeyword(result.stem);
    if (!stemEntry) return null;
    const tokenOptions = {
      normalized: stemEntry.normalized,
      stem: result.stem,
      stemConfidence: result.confidence
    };
    return createToken(word, "keyword", createPosition(startPos, endPos), tokenOptions);
  }
  /**
   * Try to extract a CSS selector at the current position.
   */
  trySelector(input, pos) {
    const selector = extractCssSelector(input, pos);
    if (selector) {
      return createToken(selector, "selector", createPosition(pos, pos + selector.length));
    }
    return null;
  }
  /**
   * Try to extract an event modifier at the current position.
   * Event modifiers are .once, .debounce(N), .throttle(N), .queue(strategy)
   */
  tryEventModifier(input, pos) {
    if (input[pos] !== ".") {
      return null;
    }
    const match = input.slice(pos).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);
    if (!match) {
      return null;
    }
    const fullMatch = match[0].replace(/(\s|\.)$/, "");
    const modifierName = fullMatch.slice(1).split("(")[0];
    const value = match[1];
    const token = createToken(
      fullMatch,
      "event-modifier",
      createPosition(pos, pos + fullMatch.length)
    );
    return {
      ...token,
      metadata: {
        modifierName,
        value: value ? modifierName === "queue" ? value : parseInt(value, 10) : void 0
      }
    };
  }
  /**
   * Try to extract a string literal at the current position.
   */
  tryString(input, pos) {
    const literal = extractStringLiteral(input, pos);
    if (literal) {
      return createToken(literal, "literal", createPosition(pos, pos + literal.length));
    }
    return null;
  }
  /**
   * Try to extract a number at the current position.
   */
  tryNumber(input, pos) {
    const number = extractNumber(input, pos);
    if (number) {
      return createToken(number, "literal", createPosition(pos, pos + number.length));
    }
    return null;
  }
  /**
   * Try to match a time unit from a list of patterns.
   *
   * @param input - Input string
   * @param pos - Position after the number
   * @param timeUnits - Array of time unit mappings (native pattern → standard suffix)
   * @param skipWhitespace - Whether to skip whitespace before time unit (default: false)
   * @returns Object with matched suffix and new position, or null if no match
   */
  tryMatchTimeUnit(input, pos, timeUnits, skipWhitespace = false) {
    let unitPos = pos;
    if (skipWhitespace) {
      while (unitPos < input.length && isWhitespace(input[unitPos])) {
        unitPos++;
      }
    }
    const remaining = input.slice(unitPos);
    for (const unit of timeUnits) {
      const candidate = remaining.slice(0, unit.length);
      const matches = unit.caseInsensitive ? candidate.toLowerCase() === unit.pattern.toLowerCase() : candidate === unit.pattern;
      if (matches) {
        if (unit.notFollowedBy) {
          const nextChar = remaining[unit.length] || "";
          if (nextChar === unit.notFollowedBy) continue;
        }
        if (unit.checkBoundary) {
          const nextChar = remaining[unit.length] || "";
          if (isAsciiIdentifierChar(nextChar)) continue;
        }
        return { suffix: unit.suffix, endPos: unitPos + unit.length };
      }
    }
    return null;
  }
  /**
   * Parse a base number (sign, integer, decimal) without time units.
   * Returns the number string and end position.
   *
   * @param input - Input string
   * @param startPos - Start position
   * @param allowSign - Whether to allow +/- sign (default: true)
   * @returns Object with number string and end position, or null
   */
  parseBaseNumber(input, startPos, allowSign = true) {
    let pos = startPos;
    let number = "";
    if (allowSign && (input[pos] === "-" || input[pos] === "+")) {
      number += input[pos++];
    }
    if (pos >= input.length || !isDigit(input[pos])) {
      return null;
    }
    while (pos < input.length && isDigit(input[pos])) {
      number += input[pos++];
    }
    if (pos < input.length && input[pos] === ".") {
      number += input[pos++];
      while (pos < input.length && isDigit(input[pos])) {
        number += input[pos++];
      }
    }
    if (!number || number === "-" || number === "+") return null;
    return { number, endPos: pos };
  }
  /**
   * Try to extract a number with native language time units.
   *
   * This is a template method that handles the common pattern:
   * 1. Parse the base number (sign, integer, decimal)
   * 2. Try to match native language time units
   * 3. Fall back to standard time units (ms, s, m, h)
   *
   * @param input - Input string
   * @param pos - Start position
   * @param nativeTimeUnits - Language-specific time unit mappings
   * @param options - Configuration options
   * @returns Token if number found, null otherwise
   */
  tryNumberWithTimeUnits(input, pos, nativeTimeUnits, options = {}) {
    const { allowSign = true, skipWhitespace = false } = options;
    const baseResult = this.parseBaseNumber(input, pos, allowSign);
    if (!baseResult) return null;
    let { number, endPos } = baseResult;
    const allUnits = [...nativeTimeUnits, ..._BaseTokenizer.STANDARD_TIME_UNITS];
    const timeMatch = this.tryMatchTimeUnit(input, endPos, allUnits, skipWhitespace);
    if (timeMatch) {
      number += timeMatch.suffix;
      endPos = timeMatch.endPos;
    }
    return createToken(number, "literal", createPosition(pos, endPos));
  }
  /**
   * Try to extract a URL at the current position.
   * Handles /path, ./path, ../path, //domain.com, http://, https://
   */
  tryUrl(input, pos) {
    const url = extractUrl(input, pos);
    if (url) {
      return createToken(url, "url", createPosition(pos, pos + url.length));
    }
    return null;
  }
  /**
   * Try to extract a variable reference (:varname) at the current position.
   * In hyperscript, :x refers to a local variable named x.
   */
  tryVariableRef(input, pos) {
    if (input[pos] !== ":") return null;
    if (pos + 1 >= input.length) return null;
    if (!isAsciiIdentifierChar(input[pos + 1])) return null;
    let endPos = pos + 1;
    while (endPos < input.length && isAsciiIdentifierChar(input[endPos])) {
      endPos++;
    }
    const varRef = input.slice(pos, endPos);
    return createToken(varRef, "identifier", createPosition(pos, endPos));
  }
  /**
   * Try to extract an operator or punctuation token at the current position.
   * Handles two-character operators (==, !=, etc.) and single-character operators.
   */
  tryOperator(input, pos) {
    const twoChar = input.slice(pos, pos + 2);
    if (["==", "!=", "<=", ">=", "&&", "||", "->"].includes(twoChar)) {
      return createToken(twoChar, "operator", createPosition(pos, pos + 2));
    }
    const oneChar = input[pos];
    if (["<", ">", "!", "+", "-", "*", "/", "="].includes(oneChar)) {
      return createToken(oneChar, "operator", createPosition(pos, pos + 1));
    }
    if (["(", ")", "{", "}", ",", ";", ":"].includes(oneChar)) {
      return createToken(oneChar, "punctuation", createPosition(pos, pos + 1));
    }
    return null;
  }
  /**
   * Try to match a multi-character particle from a list.
   *
   * Used by languages like Japanese, Korean, and Chinese that have
   * multi-character particles (e.g., Japanese から, まで, より).
   *
   * @param input - Input string
   * @param pos - Current position
   * @param particles - Array of multi-character particles to match
   * @returns Token if matched, null otherwise
   */
  tryMultiCharParticle(input, pos, particles) {
    for (const particle of particles) {
      if (input.slice(pos, pos + particle.length) === particle) {
        return createToken(particle, "particle", createPosition(pos, pos + particle.length));
      }
    }
    return null;
  }
};
/**
 * Configuration for native language time units.
 * Maps patterns to their standard suffix (ms, s, m, h).
 */
_BaseTokenizer.STANDARD_TIME_UNITS = [
  { pattern: "ms", suffix: "ms", length: 2 },
  { pattern: "s", suffix: "s", length: 1, checkBoundary: true },
  { pattern: "m", suffix: "m", length: 1, checkBoundary: true, notFollowedBy: "s" },
  { pattern: "h", suffix: "h", length: 1, checkBoundary: true }
];
var BaseTokenizer = _BaseTokenizer;

// src/generators/profiles/russian.ts
var russianProfile = {
  code: "ru",
  name: "Russian",
  nativeName: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
  direction: "ltr",
  wordOrder: "SVO",
  markingStrategy: "preposition",
  usesSpaces: true,
  defaultVerbForm: "infinitive",
  verb: {
    position: "start",
    subjectDrop: true,
    suffixes: ["\u0442\u044C", "\u0442\u044C\u0441\u044F", "\u0438\u0442\u044C", "\u0438\u0442\u044C\u0441\u044F", "\u0430\u0442\u044C", "\u0430\u0442\u044C\u0441\u044F", "\u0435\u0442\u044C", "\u0435\u0442\u044C\u0441\u044F"]
  },
  references: {
    me: "\u044F",
    it: "\u044D\u0442\u043E",
    you: "\u0442\u044B",
    result: "\u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442",
    event: "\u0441\u043E\u0431\u044B\u0442\u0438\u0435",
    target: "\u0446\u0435\u043B\u044C",
    body: "body"
  },
  possessive: {
    marker: "",
    markerPosition: "after-object",
    usePossessiveAdjectives: true,
    specialForms: {
      me: "\u043C\u043E\u0439",
      it: "\u0435\u0433\u043E",
      you: "\u0442\u0432\u043E\u0439"
    },
    keywords: {
      // "my" variants (masculine/feminine/neuter/plural)
      \u043C\u043E\u0439: "me",
      \u043C\u043E\u044F: "me",
      \u043C\u043E\u0451: "me",
      \u043C\u043E\u0438: "me",
      // "your" variants
      \u0442\u0432\u043E\u0439: "you",
      \u0442\u0432\u043E\u044F: "you",
      \u0442\u0432\u043E\u0451: "you",
      \u0442\u0432\u043E\u0438: "you",
      // "its/his/her" forms
      \u0435\u0433\u043E: "it",
      // his/its
      \u0435\u0451: "it"
      // her/its (feminine)
    }
  },
  roleMarkers: {
    destination: { primary: "\u0432", alternatives: ["\u043D\u0430", "\u043A"], position: "before" },
    source: { primary: "\u0438\u0437", alternatives: ["\u043E\u0442", "\u0441"], position: "before" },
    patient: { primary: "", position: "before" },
    style: { primary: "\u0441", alternatives: ["\u0441\u043E"], position: "before" }
  },
  keywords: {
    // Class/Attribute operations (infinitive form)
    toggle: {
      primary: "\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C",
      alternatives: ["\u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438"],
      normalized: "toggle",
      form: "infinitive"
    },
    add: { primary: "\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C", alternatives: ["\u0434\u043E\u0431\u0430\u0432\u044C"], normalized: "add", form: "infinitive" },
    remove: {
      primary: "\u0443\u0434\u0430\u043B\u0438\u0442\u044C",
      alternatives: ["\u0443\u0434\u0430\u043B\u0438", "\u0443\u0431\u0440\u0430\u0442\u044C", "\u0443\u0431\u0435\u0440\u0438"],
      normalized: "remove",
      form: "infinitive"
    },
    // Content operations
    put: {
      primary: "\u043F\u043E\u043B\u043E\u0436\u0438\u0442\u044C",
      alternatives: ["\u043F\u043E\u043B\u043E\u0436\u0438", "\u043F\u043E\u043C\u0435\u0441\u0442\u0438\u0442\u044C", "\u043F\u043E\u043C\u0435\u0441\u0442\u0438", "\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044C", "\u0432\u0441\u0442\u0430\u0432\u044C"],
      normalized: "put",
      form: "infinitive"
    },
    append: {
      primary: "\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C_\u0432_\u043A\u043E\u043D\u0435\u0446",
      alternatives: ["\u0434\u043E\u043F\u0438\u0441\u0430\u0442\u044C"],
      normalized: "append",
      form: "infinitive"
    },
    prepend: { primary: "\u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C_\u0432_\u043D\u0430\u0447\u0430\u043B\u043E", normalized: "prepend", form: "infinitive" },
    take: { primary: "\u0432\u0437\u044F\u0442\u044C", alternatives: ["\u0432\u043E\u0437\u044C\u043C\u0438"], normalized: "take", form: "infinitive" },
    make: { primary: "\u0441\u043E\u0437\u0434\u0430\u0442\u044C", alternatives: ["\u0441\u043E\u0437\u0434\u0430\u0439"], normalized: "make", form: "infinitive" },
    clone: {
      primary: "\u043A\u043B\u043E\u043D\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
      alternatives: ["\u043A\u043B\u043E\u043D\u0438\u0440\u0443\u0439"],
      normalized: "clone",
      form: "infinitive"
    },
    swap: {
      primary: "\u043F\u043E\u043C\u0435\u043D\u044F\u0442\u044C",
      alternatives: ["\u043F\u043E\u043C\u0435\u043D\u044F\u0439"],
      normalized: "swap",
      form: "infinitive"
    },
    morph: {
      primary: "\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
      alternatives: ["\u0442\u0440\u0430\u043D\u0441\u0444\u043E\u0440\u043C\u0438\u0440\u0443\u0439"],
      normalized: "morph",
      form: "infinitive"
    },
    // Variable operations
    set: {
      primary: "\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C",
      alternatives: ["\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438", "\u0437\u0430\u0434\u0430\u0442\u044C", "\u0437\u0430\u0434\u0430\u0439"],
      normalized: "set",
      form: "infinitive"
    },
    get: { primary: "\u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C", alternatives: ["\u043F\u043E\u043B\u0443\u0447\u0438"], normalized: "get", form: "infinitive" },
    increment: {
      primary: "\u0443\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C",
      alternatives: ["\u0443\u0432\u0435\u043B\u0438\u0447\u044C"],
      normalized: "increment",
      form: "infinitive"
    },
    decrement: {
      primary: "\u0443\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C",
      alternatives: ["\u0443\u043C\u0435\u043D\u044C\u0448\u0438"],
      normalized: "decrement",
      form: "infinitive"
    },
    log: { primary: "\u0437\u0430\u043F\u0438\u0441\u0430\u0442\u044C", alternatives: ["\u0437\u0430\u043F\u0438\u0448\u0438"], normalized: "log", form: "infinitive" },
    // Visibility
    show: { primary: "\u043F\u043E\u043A\u0430\u0437\u0430\u0442\u044C", alternatives: ["\u043F\u043E\u043A\u0430\u0436\u0438"], normalized: "show", form: "infinitive" },
    hide: {
      primary: "\u0441\u043A\u0440\u044B\u0442\u044C",
      alternatives: ["\u0441\u043A\u0440\u043E\u0439", "\u0441\u043F\u0440\u044F\u0442\u0430\u0442\u044C", "\u0441\u043F\u0440\u044F\u0447\u044C"],
      normalized: "hide",
      form: "infinitive"
    },
    transition: {
      primary: "\u0430\u043D\u0438\u043C\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
      alternatives: ["\u0430\u043D\u0438\u043C\u0438\u0440\u0443\u0439"],
      normalized: "transition",
      form: "infinitive"
    },
    // Events
    on: { primary: "\u043F\u0440\u0438", alternatives: ["\u043A\u043E\u0433\u0434\u0430"], normalized: "on" },
    trigger: {
      primary: "\u0432\u044B\u0437\u0432\u0430\u0442\u044C",
      alternatives: ["\u0432\u044B\u0437\u043E\u0432\u0438"],
      normalized: "trigger",
      form: "infinitive"
    },
    send: {
      primary: "\u043E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C",
      alternatives: ["\u043E\u0442\u043F\u0440\u0430\u0432\u044C"],
      normalized: "send",
      form: "infinitive"
    },
    // DOM focus
    focus: {
      primary: "\u0441\u0444\u043E\u043A\u0443\u0441\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
      alternatives: ["\u0441\u0444\u043E\u043A\u0443\u0441\u0438\u0440\u0443\u0439", "\u0444\u043E\u043A\u0443\u0441"],
      normalized: "focus",
      form: "infinitive"
    },
    blur: { primary: "\u0440\u0430\u0437\u043C\u044B\u0442\u044C", alternatives: ["\u0440\u0430\u0437\u043C\u043E\u0439"], normalized: "blur", form: "infinitive" },
    // Common event names (for event handler patterns)
    click: { primary: "\u043A\u043B\u0438\u043A", alternatives: ["\u043A\u043B\u0438\u043A\u0435", "\u043D\u0430\u0436\u0430\u0442\u0438\u0438"], normalized: "click" },
    hover: { primary: "\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u0438\u0438", alternatives: ["\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u0438\u0435"], normalized: "hover" },
    submit: { primary: "\u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0435", alternatives: ["\u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0430"], normalized: "submit" },
    input: { primary: "\u0432\u0432\u043E\u0434\u0435", alternatives: ["\u0432\u0432\u043E\u0434"], normalized: "input" },
    change: { primary: "\u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0438", alternatives: ["\u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0435"], normalized: "change" },
    // Navigation
    go: {
      primary: "\u043F\u0435\u0440\u0435\u0439\u0442\u0438",
      alternatives: ["\u043F\u0435\u0440\u0435\u0439\u0434\u0438", "\u0438\u0434\u0442\u0438", "\u0438\u0434\u0438"],
      normalized: "go",
      form: "infinitive"
    },
    // Async
    wait: {
      primary: "\u0436\u0434\u0430\u0442\u044C",
      alternatives: ["\u0436\u0434\u0438", "\u043F\u043E\u0434\u043E\u0436\u0434\u0438"],
      normalized: "wait",
      form: "infinitive"
    },
    fetch: {
      primary: "\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",
      alternatives: ["\u0437\u0430\u0433\u0440\u0443\u0437\u0438"],
      normalized: "fetch",
      form: "infinitive"
    },
    settle: { primary: "\u0441\u0442\u0430\u0431\u0438\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C", normalized: "settle", form: "infinitive" },
    // Control flow
    if: { primary: "\u0435\u0441\u043B\u0438", normalized: "if" },
    when: { primary: "\u043A\u043E\u0433\u0434\u0430", normalized: "when" },
    where: { primary: "\u0433\u0434\u0435", normalized: "where" },
    else: { primary: "\u0438\u043D\u0430\u0447\u0435", normalized: "else" },
    repeat: {
      primary: "\u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C",
      alternatives: ["\u043F\u043E\u0432\u0442\u043E\u0440\u0438"],
      normalized: "repeat",
      form: "infinitive"
    },
    for: { primary: "\u0434\u043B\u044F", alternatives: ["\u043A\u0430\u0436\u0434\u044B\u0439"], normalized: "for" },
    while: { primary: "\u043F\u043E\u043A\u0430", normalized: "while" },
    continue: {
      primary: "\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C",
      alternatives: ["\u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438"],
      normalized: "continue",
      form: "infinitive"
    },
    halt: {
      primary: "\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C",
      alternatives: ["\u043E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0441\u044C", "\u0441\u0442\u043E\u043F"],
      normalized: "halt",
      form: "infinitive"
    },
    throw: { primary: "\u0431\u0440\u043E\u0441\u0438\u0442\u044C", alternatives: ["\u0431\u0440\u043E\u0441\u044C"], normalized: "throw", form: "infinitive" },
    call: { primary: "\u0432\u044B\u0437\u0432\u0430\u0442\u044C", alternatives: ["\u0432\u044B\u0437\u043E\u0432\u0438"], normalized: "call", form: "infinitive" },
    return: {
      primary: "\u0432\u0435\u0440\u043D\u0443\u0442\u044C",
      alternatives: ["\u0432\u0435\u0440\u043D\u0438"],
      normalized: "return",
      form: "infinitive"
    },
    then: { primary: "\u0437\u0430\u0442\u0435\u043C", alternatives: ["\u043F\u043E\u0442\u043E\u043C", "\u0442\u043E\u0433\u0434\u0430"], normalized: "then" },
    and: { primary: "\u0438", normalized: "and" },
    end: { primary: "\u043A\u043E\u043D\u0435\u0446", normalized: "end" },
    // Advanced
    js: { primary: "js", normalized: "js" },
    async: { primary: "\u0430\u0441\u0438\u043D\u0445\u0440\u043E\u043D\u043D\u043E", alternatives: ["async"], normalized: "async" },
    tell: { primary: "\u0441\u043A\u0430\u0437\u0430\u0442\u044C", alternatives: ["\u0441\u043A\u0430\u0436\u0438"], normalized: "tell", form: "infinitive" },
    default: { primary: "\u043F\u043E_\u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E", normalized: "default" },
    init: {
      primary: "\u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
      alternatives: ["\u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u0443\u0439"],
      normalized: "init",
      form: "infinitive"
    },
    behavior: { primary: "\u043F\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u0435", normalized: "behavior" },
    install: { primary: "\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C_\u043F\u0430\u043A\u0435\u0442", normalized: "install", form: "infinitive" },
    measure: {
      primary: "\u0438\u0437\u043C\u0435\u0440\u0438\u0442\u044C",
      alternatives: ["\u0438\u0437\u043C\u0435\u0440\u044C"],
      normalized: "measure",
      form: "infinitive"
    },
    // Modifiers
    into: { primary: "\u0432", alternatives: ["\u0432\u043E"], normalized: "into" },
    before: { primary: "\u0434\u043E", alternatives: ["\u043F\u0435\u0440\u0435\u0434"], normalized: "before" },
    after: { primary: "\u043F\u043E\u0441\u043B\u0435", normalized: "after" },
    // Event modifiers
    until: { primary: "\u0434\u043E", alternatives: ["\u043F\u043E\u043A\u0430_\u043D\u0435"], normalized: "until" },
    event: { primary: "\u0441\u043E\u0431\u044B\u0442\u0438\u0435", normalized: "event" },
    from: { primary: "\u0438\u0437", alternatives: ["\u043E\u0442", "\u0441"], normalized: "from" }
  },
  eventHandler: {
    keyword: { primary: "\u043F\u0440\u0438", alternatives: ["\u043A\u043E\u0433\u0434\u0430"], normalized: "on" },
    sourceMarker: { primary: "\u043D\u0430", alternatives: ["\u0432", "\u043F\u0440\u0438"], position: "before" },
    // Event marker: при (at/on/upon), used in SVO pattern
    // Pattern: при [event] [verb] [patient] на [destination?]
    // Example: при клике переключить .active на #button
    eventMarker: { primary: "\u043F\u0440\u0438", alternatives: ["\u043A\u043E\u0433\u0434\u0430"], position: "before" },
    temporalMarkers: ["\u043A\u043E\u0433\u0434\u0430", "\u0435\u0441\u043B\u0438"]
    // temporal conjunctions (when, if)
  }
};

// src/tokenizers/russian.ts
var { isLetter: isRussianLetter, isIdentifierChar: isRussianIdentifierChar } = createLatinCharClassifiers(/[a-zA-Zа-яА-ЯёЁ]/);
var PREPOSITIONS = /* @__PURE__ */ new Set([
  "\u0432",
  // in
  "\u0432\u043E",
  // in (before consonant clusters)
  "\u043D\u0430",
  // on
  "\u0441",
  // with, from
  "\u0441\u043E",
  // with (before consonant clusters)
  "\u043A",
  // to, towards
  "\u043A\u043E",
  // to (before consonant clusters)
  "\u043E",
  // about
  "\u043E\u0431",
  // about (before vowels)
  "\u043E\u0431\u043E",
  // about (before consonant clusters)
  "\u0443",
  // at, by
  "\u043E\u0442",
  // from
  "\u0434\u043E",
  // until, to
  "\u0438\u0437",
  // from, out of
  "\u0437\u0430",
  // behind, for
  "\u043F\u043E",
  // along, by
  "\u043F\u043E\u0434",
  // under
  "\u043D\u0430\u0434",
  // above
  "\u043F\u0435\u0440\u0435\u0434",
  // in front of
  "\u043F\u0435\u0440\u0435\u0434\u043E",
  // in front of (before consonant clusters)
  "\u043C\u0435\u0436\u0434\u0443",
  // between
  "\u0447\u0435\u0440\u0435\u0437",
  // through
  "\u0431\u0435\u0437",
  // without
  "\u0434\u043B\u044F",
  // for
  "\u043F\u0440\u0438",
  // at, during
  "\u043F\u0440\u043E",
  // about
  "\u043F\u043E\u0441\u043B\u0435",
  // after
  "\u0432\u043E\u043A\u0440\u0443\u0433",
  // around
  "\u043F\u0440\u043E\u0442\u0438\u0432",
  // against
  "\u0432\u043C\u0435\u0441\u0442\u043E",
  // instead of
  "\u043A\u0440\u043E\u043C\u0435",
  // except
  "\u0441\u0440\u0435\u0434\u0438"
  // among
]);
var RUSSIAN_EXTRAS = [
  // Values/Literals
  { native: "\u0438\u0441\u0442\u0438\u043D\u0430", normalized: "true" },
  { native: "\u043F\u0440\u0430\u0432\u0434\u0430", normalized: "true" },
  { native: "\u043B\u043E\u0436\u044C", normalized: "false" },
  { native: "null", normalized: "null" },
  { native: "\u043D\u0435\u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0435\u043D\u043E", normalized: "undefined" },
  // Positional
  { native: "\u043F\u0435\u0440\u0432\u044B\u0439", normalized: "first" },
  { native: "\u043F\u0435\u0440\u0432\u0430\u044F", normalized: "first" },
  { native: "\u043F\u0435\u0440\u0432\u043E\u0435", normalized: "first" },
  { native: "\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0439", normalized: "last" },
  { native: "\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u044F\u044F", normalized: "last" },
  { native: "\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0435\u0435", normalized: "last" },
  { native: "\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439", normalized: "next" },
  { native: "\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0430\u044F", normalized: "next" },
  { native: "\u043F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0438\u0439", normalized: "previous" },
  { native: "\u043F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F", normalized: "previous" },
  { native: "\u0431\u043B\u0438\u0436\u0430\u0439\u0448\u0438\u0439", normalized: "closest" },
  { native: "\u0440\u043E\u0434\u0438\u0442\u0435\u043B\u044C", normalized: "parent" },
  // Events
  { native: "\u043A\u043B\u0438\u043A", normalized: "click" },
  { native: "\u043D\u0430\u0436\u0430\u0442\u0438\u0435", normalized: "click" },
  { native: "click", normalized: "click" },
  { native: "\u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0435", normalized: "change" },
  { native: "\u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0430", normalized: "submit" },
  { native: "\u043A\u043B\u0430\u0432\u0438\u0448\u0430", normalized: "keydown" },
  { native: "\u043D\u0430\u0432\u0435\u0434\u0435\u043D\u0438\u0435", normalized: "mouseover" },
  { native: "\u0443\u0445\u043E\u0434", normalized: "mouseout" },
  { native: "\u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0430", normalized: "load" },
  { native: "\u043F\u0440\u043E\u043A\u0440\u0443\u0442\u043A\u0430", normalized: "scroll" },
  { native: "\u0432\u0432\u043E\u0434", normalized: "input" },
  // References - possessive forms
  { native: "\u043C\u043E\u0439", normalized: "my" },
  { native: "\u043C\u043E\u044F", normalized: "my" },
  { native: "\u043C\u043E\u0451", normalized: "my" },
  { native: "\u043C\u043E\u0438", normalized: "my" },
  // Time units
  { native: "\u0441\u0435\u043A\u0443\u043D\u0434\u0430", normalized: "s" },
  { native: "\u0441\u0435\u043A\u0443\u043D\u0434\u044B", normalized: "s" },
  { native: "\u0441\u0435\u043A\u0443\u043D\u0434", normalized: "s" },
  { native: "\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0430", normalized: "ms" },
  { native: "\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u044B", normalized: "ms" },
  { native: "\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434", normalized: "ms" },
  { native: "\u043C\u0438\u043D\u0443\u0442\u0430", normalized: "m" },
  { native: "\u043C\u0438\u043D\u0443\u0442\u044B", normalized: "m" },
  { native: "\u043C\u0438\u043D\u0443\u0442", normalized: "m" },
  { native: "\u0447\u0430\u0441", normalized: "h" },
  { native: "\u0447\u0430\u0441\u0430", normalized: "h" },
  { native: "\u0447\u0430\u0441\u043E\u0432", normalized: "h" },
  // Logical/conditional
  { native: "\u0438\u043B\u0438", normalized: "or" },
  { native: "\u043D\u0435", normalized: "not" },
  { native: "\u0435\u0441\u0442\u044C", normalized: "is" },
  { native: "\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442", normalized: "exists" },
  { native: "\u043F\u0443\u0441\u0442\u043E\u0439", normalized: "empty" },
  { native: "\u043F\u0443\u0441\u0442\u0430\u044F", normalized: "empty" },
  { native: "\u043F\u0443\u0441\u0442\u043E\u0435", normalized: "empty" }
];
var RussianTokenizer = class extends BaseTokenizer {
  constructor() {
    super();
    this.language = "ru";
    this.direction = "ltr";
    this.initializeKeywordsFromProfile(russianProfile, RUSSIAN_EXTRAS);
  }
  tokenize(input) {
    const tokens = [];
    let pos = 0;
    while (pos < input.length) {
      if (isWhitespace(input[pos])) {
        pos++;
        continue;
      }
      if (isSelectorStart(input[pos])) {
        const modifierToken = this.tryEventModifier(input, pos);
        if (modifierToken) {
          tokens.push(modifierToken);
          pos = modifierToken.position.end;
          continue;
        }
        const selectorToken = this.trySelector(input, pos);
        if (selectorToken) {
          tokens.push(selectorToken);
          pos = selectorToken.position.end;
          continue;
        }
      }
      if (isQuote(input[pos])) {
        const stringToken = this.tryString(input, pos);
        if (stringToken) {
          tokens.push(stringToken);
          pos = stringToken.position.end;
          continue;
        }
      }
      if (isUrlStart(input, pos)) {
        const urlToken = this.tryUrl(input, pos);
        if (urlToken) {
          tokens.push(urlToken);
          pos = urlToken.position.end;
          continue;
        }
      }
      if (isDigit(input[pos]) || input[pos] === "-" && pos + 1 < input.length && isDigit(input[pos + 1])) {
        const numberToken = this.extractNumber(input, pos);
        if (numberToken) {
          tokens.push(numberToken);
          pos = numberToken.position.end;
          continue;
        }
      }
      const varToken = this.tryVariableRef(input, pos);
      if (varToken) {
        tokens.push(varToken);
        pos = varToken.position.end;
        continue;
      }
      if (isRussianLetter(input[pos])) {
        const wordToken = this.extractWord(input, pos);
        if (wordToken) {
          tokens.push(wordToken);
          pos = wordToken.position.end;
          continue;
        }
      }
      const operatorToken = this.tryOperator(input, pos);
      if (operatorToken) {
        tokens.push(operatorToken);
        pos = operatorToken.position.end;
        continue;
      }
      pos++;
    }
    return new TokenStreamImpl(tokens, "ru");
  }
  classifyToken(token) {
    const lower = token.toLowerCase();
    if (PREPOSITIONS.has(lower)) return "particle";
    if (this.isKeyword(lower)) return "keyword";
    if (token.startsWith("#") || token.startsWith(".") || token.startsWith("[")) return "selector";
    if (token.startsWith('"') || token.startsWith("'")) return "literal";
    if (/^\d/.test(token)) return "literal";
    return "identifier";
  }
  extractWord(input, startPos) {
    let pos = startPos;
    let word = "";
    while (pos < input.length && isRussianIdentifierChar(input[pos])) {
      word += input[pos++];
    }
    if (!word) return null;
    const lower = word.toLowerCase();
    if (PREPOSITIONS.has(lower)) {
      return createToken(word, "particle", createPosition(startPos, pos));
    }
    const keywordEntry = this.lookupKeyword(lower);
    if (keywordEntry) {
      return createToken(word, "keyword", createPosition(startPos, pos), keywordEntry.normalized);
    }
    return createToken(word, "identifier", createPosition(startPos, pos));
  }
  extractNumber(input, startPos) {
    let pos = startPos;
    let number = "";
    if (input[pos] === "-" || input[pos] === "+") {
      number += input[pos++];
    }
    while (pos < input.length && isDigit(input[pos])) {
      number += input[pos++];
    }
    if (pos < input.length && input[pos] === ".") {
      number += input[pos++];
      while (pos < input.length && isDigit(input[pos])) {
        number += input[pos++];
      }
    }
    let unitPos = pos;
    while (unitPos < input.length && isWhitespace(input[unitPos])) {
      unitPos++;
    }
    const remaining = input.slice(unitPos).toLowerCase();
    if (remaining.startsWith("\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434") || remaining.startsWith("\u043C\u0441")) {
      if (remaining.startsWith("\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434")) {
        number += "ms";
        pos = unitPos + 11;
        if (remaining.length > 11 && /[аы]/.test(remaining[11])) {
          pos++;
        }
      } else {
        number += "ms";
        pos = unitPos + 2;
      }
    } else if (remaining.startsWith("\u0441\u0435\u043A\u0443\u043D\u0434") || remaining.startsWith("\u0441\u0435\u043A")) {
      if (remaining.startsWith("\u0441\u0435\u043A\u0443\u043D\u0434")) {
        number += "s";
        pos = unitPos + 6;
        if (remaining.length > 6 && /[аы]/.test(remaining[6])) {
          pos++;
        }
      } else {
        number += "s";
        pos = unitPos + 3;
      }
    } else if (remaining.startsWith("\u043C\u0438\u043D\u0443\u0442") || remaining.startsWith("\u043C\u0438\u043D")) {
      if (remaining.startsWith("\u043C\u0438\u043D\u0443\u0442")) {
        number += "m";
        pos = unitPos + 5;
        if (remaining.length > 5 && /[аы]/.test(remaining[5])) {
          pos++;
        }
      } else {
        number += "m";
        pos = unitPos + 3;
      }
    } else if (remaining.startsWith("\u0447\u0430\u0441")) {
      number += "h";
      pos = unitPos + 3;
      if (remaining.length > 3 && remaining[3] === "\u0430") {
        pos++;
      } else if (remaining.length > 3 && remaining.slice(3, 5) === "\u043E\u0432") {
        pos += 2;
      }
    } else if (remaining.startsWith("ms")) {
      number += "ms";
      pos = unitPos + 2;
    } else if (remaining.startsWith("s") && !remaining.startsWith("se")) {
      number += "s";
      pos = unitPos + 1;
    }
    if (!number || number === "-" || number === "+") return null;
    return createToken(number, "literal", createPosition(startPos, pos));
  }
};
var russianTokenizer = new RussianTokenizer();

// src/languages/ru.ts
registerLanguage("ru", russianTokenizer, russianProfile);
export {
  russianProfile,
  russianTokenizer
};
//# sourceMappingURL=ru.js.map