"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.a = stripSilentToken;exports.i = isSilentReplyText;exports.n = void 0;exports.r = isSilentReplyPrefixText;exports.t = void 0;var _loggerU3s76KST = require("./logger-U3s76KST.js"); //#region src/auto-reply/tokens.ts const HEARTBEAT_TOKEN = exports.t = "HEARTBEAT_OK"; const SILENT_REPLY_TOKEN = exports.n = "NO_REPLY"; const silentExactRegexByToken = /* @__PURE__ */new Map(); const silentTrailingRegexByToken = /* @__PURE__ */new Map(); function getSilentExactRegex(token) { const cached = silentExactRegexByToken.get(token); if (cached) return cached; const escaped = (0, _loggerU3s76KST.v)(token); const regex = new RegExp(`^\\s*${escaped}\\s*$`); silentExactRegexByToken.set(token, regex); return regex; } function getSilentTrailingRegex(token) { const cached = silentTrailingRegexByToken.get(token); if (cached) return cached; const escaped = (0, _loggerU3s76KST.v)(token); const regex = new RegExp(`(?:^|\\s+|\\*+)${escaped}\\s*$`); silentTrailingRegexByToken.set(token, regex); return regex; } function isSilentReplyText(text, token = SILENT_REPLY_TOKEN) { if (!text) return false; return getSilentExactRegex(token).test(text); } /** * Strip a trailing silent reply token from mixed-content text. * Returns the remaining text with the token removed (trimmed). * If the result is empty, the entire message should be treated as silent. */ function stripSilentToken(text, token = SILENT_REPLY_TOKEN) { return text.replace(getSilentTrailingRegex(token), "").trim(); } function isSilentReplyPrefixText(text, token = SILENT_REPLY_TOKEN) { if (!text) return false; const trimmed = text.trimStart(); if (!trimmed) return false; if (trimmed !== trimmed.toUpperCase()) return false; const normalized = trimmed.toUpperCase(); if (!normalized) return false; if (normalized.length < 2) return false; if (/[^A-Z_]/.test(normalized)) return false; const tokenUpper = token.toUpperCase(); if (!tokenUpper.startsWith(normalized)) return false; if (normalized.includes("_")) return true; return tokenUpper === "NO_REPLY" && normalized === "NO"; } //#endregion /* v9-3dc6490afbce3fa0 */