(text)
| 310 | } |
| 311 | |
| 312 | function decodeEscapedText(text) { |
| 313 | if (!text) return ''; |
| 314 | |
| 315 | const trimmed = text.trim(); |
| 316 | if (trimmed.length >= 2 && trimmed.startsWith('"') && trimmed.endsWith('"')) { |
| 317 | try { |
| 318 | return JSON.parse(trimmed); |
| 319 | } catch (error) { |
| 320 | // Fall back to tolerant decoding below. |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | return text |
| 325 | .replace(/\\u\{([0-9a-fA-F]+)\}/g, (_, hex) => { |
| 326 | const codePoint = parseInt(hex, 16); |
| 327 | return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : _; |
| 328 | }) |
| 329 | .replace(/\\u([0-9a-fA-F]{4})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16))) |
| 330 | .replace(/\\x([0-9a-fA-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16))) |
| 331 | .replace(/\\n/g, '\n') |
| 332 | .replace(/\\r/g, '\r') |
| 333 | .replace(/\\t/g, '\t') |
| 334 | .replace(/\\"/g, '"') |
| 335 | .replace(/\\'/g, "'") |
| 336 | .replace(/\\\\/g, '\\'); |
| 337 | } |
| 338 | |
| 339 | function setupModalClickHandlers() { |
| 340 | elements.presetModal.addEventListener('click', (e) => { |
no outgoing calls
no test coverage detected