export const loadingMessages = [ 'Searching The Times archive...', 'Visiting Diddly squat farm...', 'Kicking the tires...', 'Looking under the hood...', 'Rewatching Top Gear episodes...', 'Arguing about electric cars...', 'Feeding the cows...', 'Tilling the soil...' ]; export function decodeUnicodeEscapes(str: string): string { const replacedStr = str.replace(/\\u([0-9a-fA-F]{4})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)) ); // Strip control characters without using a control regex (lint-safe) let out = ''; for (let i = 0; i < replacedStr.length; i++) { const code = replacedStr.charCodeAt(i); if (code >= 32 && code !== 127) { out += replacedStr[i]; } } return out; } export function formatSnippet(snippet: string): string { if (!snippet) { return ''; } if (snippet.startsWith('"') && snippet.endsWith('"')) { return decodeUnicodeEscapes(snippet); } return `"${decodeUnicodeEscapes(snippet)}"`; }