// Emoji Library for P4RS3LT0NGV3 // Create namespace for emoji library window.emojiLibrary = {}; // Polyfill for Intl.Segmenter if not available if (!Intl.Segmenter) { console.warn('Intl.Segmenter not available, falling back to basic character splitting'); } // Helper function to properly split text into grapheme clusters (emojis) window.emojiLibrary.splitEmojis = function(text) { if (Intl.Segmenter) { const segmenter = new Intl.Segmenter('en', { granularity: 'grapheme' }); return Array.from(segmenter.segment(text), ({ segment }) => segment); } return Array.from(text); }; // Helper function to properly join emojis window.emojiLibrary.joinEmojis = function(emojis) { return emojis.join(''); }; // Define emoji categories with specific emojis for each category window.emojiLibrary.EMOJIS = { nature: ["๐ŸŒˆ", "๐ŸŒž", "๐ŸŒ‘", "๐ŸŒ’", "๐ŸŒ“", "๐ŸŒ”", "๐ŸŒ•", "๐ŸŒ–", "๐ŸŒ—", "๐ŸŒ˜", "๐ŸฆŠ", "๐Ÿฆ", "๐Ÿฏ", "๐Ÿฎ", "๐Ÿท", "๐Ÿธ", "๐Ÿต", "๐Ÿ”", "๐Ÿง", "๐Ÿฆ", "๐Ÿค", "๐Ÿฆ†", "๐Ÿฆ…", "๐Ÿฆ‰", "๐Ÿฆ‡", "๐Ÿบ", "๐Ÿ—", "๐Ÿด", "๐Ÿฆ„", "๐Ÿ", "๐Ÿ›", "๐Ÿฆ‹", "๐ŸŒ", "๐Ÿž", "๐Ÿœ", "๐Ÿ•ท๏ธ", "๐Ÿฆ‚", "๐ŸฆŸ", "๐Ÿฆ ", "๐Ÿชฑ"], mystical: ["๐Ÿง™", "๐Ÿง™โ€โ™‚๏ธ", "๐Ÿง™โ€โ™€๏ธ", "๐Ÿงš", "๐Ÿงšโ€โ™‚๏ธ", "๐Ÿงšโ€โ™€๏ธ", "๐Ÿง›", "๐Ÿง›โ€โ™‚๏ธ", "๐Ÿง›โ€โ™€๏ธ", "๐Ÿงœ", "๐Ÿงœโ€โ™‚๏ธ", "๐Ÿงœโ€โ™€๏ธ", "๐Ÿ‘น", "๐Ÿ‘บ", "๐Ÿ‘ป", "๐Ÿ‘ฝ", "๐Ÿ‘พ", "๐Ÿฒ", "๐Ÿ”ฎ", "๐Ÿ", "๐Ÿ‰", "๐Ÿฆ„", "โš—๏ธ", "๐Ÿ”ฏ", "๐Ÿ”ฑ", "โšœ๏ธ", "โœจ", "๐ŸŒ ", "๐ŸŒ‹", "๐Ÿ’Ž", "๐Ÿฉธ"], faces_people: ["๐Ÿ˜€", "๐Ÿ˜", "๐Ÿ˜‚", "๐Ÿคฃ", "๐Ÿ˜ƒ", "๐Ÿ˜„", "๐Ÿ˜…", "๐Ÿ˜†", "๐Ÿ˜‰", "๐Ÿ˜Š", "๐Ÿ˜‹", "๐Ÿ˜Ž", "๐Ÿ˜", "๐Ÿ˜˜", "๐Ÿฅฐ", "๐Ÿ˜—", "๐Ÿ˜™", "๐Ÿ˜š", "๐Ÿ™‚", "๐Ÿค—", "๐Ÿคฉ", "๐Ÿค”", "๐Ÿคจ", "๐Ÿ˜", "๐Ÿ˜‘", "๐Ÿ˜ถ", "๐Ÿ™„", "๐Ÿ˜", "๐Ÿ˜ฃ", "๐Ÿ˜ฅ", "๐Ÿ˜ฎ", "๐Ÿค", "๐Ÿ˜ฏ", "๐Ÿ˜ช", "๐Ÿ˜ซ", "๐Ÿ˜ด", "๐Ÿ˜Œ", "๐Ÿ˜›", "๐Ÿ˜œ", "๐Ÿ˜", "๐Ÿคค", "๐Ÿ˜’", "๐Ÿ˜“", "๐Ÿ˜”", "๐Ÿ˜•", "๐Ÿ™ƒ", "๐Ÿค‘", "๐Ÿ˜ฒ", "๐Ÿ™", "๐Ÿ˜–", "๐Ÿ˜ž", "๐Ÿ˜Ÿ", "๐Ÿ˜ค", "๐Ÿ˜ข", "๐Ÿ˜ญ", "๐Ÿ˜ง", "๐Ÿ˜จ", "๐Ÿ˜ฉ", "๐Ÿคฏ", "๐Ÿ˜ฑ", "๐Ÿ˜ณ", "๐Ÿฅต", "๐Ÿฅถ", "๐Ÿ˜ก", "๐Ÿ˜ ", "๐Ÿคฌ", "๐Ÿ˜ท", "๐Ÿค’", "๐Ÿค•", "๐Ÿคข", "๐Ÿคฎ", "๐Ÿคง", "๐Ÿ˜‡", "๐Ÿฅณ", "๐Ÿฅด", "๐Ÿฅบ", "๐Ÿง", "๐Ÿฅฑ", "๐Ÿง "], gestures: ["๐Ÿ‘", "๐Ÿ‘Ž", "๐Ÿ‘Œ", "โœŒ๏ธ", "๐Ÿคž", "๐ŸคŸ", "๐Ÿค˜", "๐Ÿค™", "๐Ÿ‘ˆ", "๐Ÿ‘‰", "๐Ÿ‘†", "๐Ÿ‘‡", "๐Ÿ–•", "โ˜๏ธ", "โœ‹", "๐Ÿคš", "๐Ÿ–๏ธ", "๐Ÿ––", "๐Ÿ‘‹", "๐Ÿค", "๐Ÿ‘", "๐Ÿ™Œ", "๐Ÿ‘", "๐Ÿค", "๐Ÿ™"], animals_nature: ["๐Ÿ‡", "๐ŸฆŠ", "๐Ÿฆ", "๐Ÿฏ", "๐Ÿฎ", "๐Ÿท", "๐Ÿธ", "๐Ÿต", "๐Ÿ”", "๐Ÿง", "๐Ÿฆ", "๐Ÿค", "๐Ÿฆ†", "๐Ÿฆ…", "๐Ÿฆ‰", "๐Ÿฆ‡", "๐Ÿบ", "๐Ÿ—", "๐Ÿด", "๐Ÿ", "๐Ÿ›", "๐Ÿฆ‹", "๐ŸŒ", "๐Ÿž", "๐Ÿœ", "๐Ÿ•ท๏ธ", "๐Ÿฆ‚", "๐Ÿ", "๐Ÿฆจ", "๐Ÿฆฉ", "๐Ÿฆซ", "๐Ÿฆฌ", "๐Ÿปโ€โ„๏ธ", "๐Ÿผ", "๐Ÿจ", "๐Ÿ•", "๐Ÿถ", "๐Ÿฉ", "๐Ÿˆ", "๐Ÿฑ"], activities_sports: ["โšฝ", "๐Ÿ€", "๐Ÿˆ", "๐Ÿ", "๐Ÿ‰", "๐ŸŽพ", "๐ŸŽณ", "๐Ÿ‘", "๐Ÿ’", "๐Ÿ“", "๐Ÿธ", "๐ŸฅŠ", "๐Ÿฅ‹", "๐Ÿฅ…", "๐Ÿคพ", "๐ŸŽฟ", "๐Ÿ„", "๐Ÿ‚", "๐ŸŠ", "๐Ÿ‹๏ธ", "๐Ÿคผ", "๐Ÿคธ", "๐Ÿคบ", "๐Ÿคฝ", "๐Ÿคน", "๐ŸŽฏ", "๐ŸŽฑ", "๐ŸŽฝ", "๐Ÿšด", "๐Ÿšต"], technology_objects: ["๐Ÿ’ป", "โŒจ๏ธ", "๐Ÿ–ฅ๏ธ", "๐Ÿ–ฑ๏ธ", "๐Ÿ–จ๏ธ", "๐Ÿ“ฑ", "โ˜Ž๏ธ", "๐Ÿ“ž", "๐Ÿ“Ÿ", "๐Ÿ“ ", "๐Ÿ“บ", "๐Ÿ“ป", "๐ŸŽ™๏ธ", "๐ŸŽš๏ธ", "๐ŸŽ›๏ธ", "๐Ÿงญ", "๐Ÿ“ก", "๐Ÿ”‹", "๐Ÿ”Œ", "๐Ÿ’ก", "๐Ÿ›ข๏ธ", "๐Ÿ’ธ", "๐Ÿ’ต", "๐Ÿ’ณ", "๐Ÿ”‘", "๐Ÿ”“", "๐Ÿ”’"], mystical_fantasy: ["๐Ÿง™", "๐Ÿงš", "๐Ÿง›", "๐Ÿงœ", "๐Ÿ‘น", "๐Ÿ‘บ", "๐Ÿ‘ป", "๐Ÿ‘ฝ", "๐Ÿ‘พ", "๐Ÿ”ฎ", "๐Ÿช„", "๐Ÿ‰", "๐Ÿฒ", "๐Ÿฆ„"], nature_weather: ["๐ŸŒˆ", "๐ŸŒž", "๐ŸŒ™", "โญ", "๐ŸŒŸ", "โšก", "โ„๏ธ", "๐Ÿ”ฅ", "๐Ÿ’ง", "๐ŸŒŠ", "๐ŸŒช๏ธ", "๐ŸŒ‹"], symbols: ["โค๏ธ", "๐Ÿ’›", "๐Ÿ’š", "๐Ÿ’™", "๐Ÿ’œ", "๐Ÿ’”", "๐Ÿ’•", "๐Ÿ’ž", "๐Ÿ’“", "๐Ÿ’—", "๐Ÿ’–", "๐Ÿ’˜", "๐Ÿ’", "๐Ÿ’Ÿ", "๐Ÿ’ข", "๐Ÿ’ฃ", "๐Ÿ’ฅ", "๐Ÿ’ฆ", "๐Ÿ’จ", "๐Ÿ’ฉ", "๐Ÿ’ซ", "๐Ÿ’ฌ", "๐Ÿ’ ", "๐Ÿ’ฎ"], flags: ["๐Ÿ", "๐Ÿšฉ", "๐ŸŽŒ", "๐Ÿด", "๐Ÿณ๏ธ", "๐Ÿณ๏ธโ€๐ŸŒˆ", "๐Ÿณ๏ธโ€โšง๏ธ", "๐Ÿดโ€โ˜ ๏ธ", "๐Ÿ‡บ๐Ÿ‡ธ", "๐Ÿ‡จ๐Ÿ‡ฆ", "๐Ÿ‡ฌ๐Ÿ‡ง", "๐Ÿ‡ฉ๐Ÿ‡ช", "๐Ÿ‡ซ๐Ÿ‡ท", "๐Ÿ‡ฎ๐Ÿ‡น", "๐Ÿ‡ฏ๐Ÿ‡ต", "๐Ÿ‡ฐ๐Ÿ‡ท", "๐Ÿ‡ท๐Ÿ‡บ", "๐Ÿ‡จ๐Ÿ‡ณ", "๐Ÿ‡ฎ๐Ÿ‡ณ", "๐Ÿ‡ง๐Ÿ‡ท", "๐Ÿ‡ฆ๐Ÿ‡บ", "๐Ÿ‡ช๐Ÿ‡ธ", "๐Ÿ‡ณ๐Ÿ‡ฑ", "๐Ÿ‡ธ๐Ÿ‡ช"] }; // Define standard emoji categories window.emojiLibrary.CATEGORIES = [ { id: 'all', name: 'All Emojis', icon: '๐Ÿ”' }, { id: 'faces_people', name: 'Faces & People', icon: '๐Ÿ˜€' }, { id: 'gestures', name: 'Gestures', icon: '๐Ÿ‘' }, { id: 'animals_nature', name: 'Animals & Nature', icon: '๐ŸฆŠ' }, { id: 'activities_sports', name: 'Activities & Sports', icon: 'โšฝ' }, { id: 'technology_objects', name: 'Tech & Objects', icon: '๐Ÿ’ป' }, { id: 'mystical_fantasy', name: 'Mystical & Fantasy', icon: '๐Ÿง™' }, { id: 'nature_weather', name: 'Nature & Weather', icon: '๐ŸŒˆ' }, { id: 'symbols', name: 'Symbols', icon: 'โค๏ธ' }, { id: 'flags', name: 'Flags', icon: '๐Ÿ' } ]; // Auto-generate EMOJI_LIST from the categorized EMOJIS object // This ensures a single source of truth for all emojis window.emojiLibrary.EMOJI_LIST = (() => { const allEmojis = []; // Combine all emojis from all categories Object.values(window.emojiLibrary.EMOJIS).forEach(categoryEmojis => { allEmojis.push(...categoryEmojis); }); // Remove duplicates using Set and return as array return Array.from(new Set(allEmojis)); })(); // Function to render emoji grid with categories window.emojiLibrary.renderEmojiGrid = function(containerId, onEmojiSelect, filteredList) { console.log('Rendering emoji grid to:', containerId); // Get container by ID const container = document.getElementById(containerId); if (!container) { console.error('Container not found:', containerId); return; } // Clear container container.innerHTML = ''; // Add header with instruction message const emojiHeader = document.createElement('div'); emojiHeader.className = 'emoji-header'; emojiHeader.innerHTML = '

Choose an Emoji

Click any emoji to copy your hidden message

'; container.appendChild(emojiHeader); // Create category tabs const categoryTabs = document.createElement('div'); categoryTabs.className = 'emoji-category-tabs'; // Add category tabs window.emojiLibrary.CATEGORIES.forEach(category => { const tab = document.createElement('button'); tab.className = 'emoji-category-tab'; if (category.id === 'all') { tab.classList.add('active'); } tab.setAttribute('data-category', category.id); tab.innerHTML = `${category.icon} ${category.name}`; categoryTabs.appendChild(tab); }); container.appendChild(categoryTabs); // Create emoji grid with enforced styling const gridContainer = document.createElement('div'); gridContainer.className = 'emoji-grid'; // Get the active category let activeCategory = 'all'; const activeCategoryTab = container.querySelector('.emoji-category-tab.active'); if (activeCategoryTab) { activeCategory = activeCategoryTab.getAttribute('data-category'); } // Determine which emojis to show based on category and filter let emojisToShow = []; if (filteredList && filteredList.length > 0) { // If we have a filtered list (from search), use that emojisToShow = filteredList; } else if (activeCategory === 'all') { // For 'all' category, combine all emojis from the categories and deduplicate Object.values(window.emojiLibrary.EMOJIS).forEach(categoryEmojis => { emojisToShow = [...emojisToShow, ...categoryEmojis]; }); // Remove duplicates using Set emojisToShow = Array.from(new Set(emojisToShow)); } else if (window.emojiLibrary.EMOJIS[activeCategory]) { // For specific category, use emojis from that category emojisToShow = window.emojiLibrary.EMOJIS[activeCategory]; } console.log(`Adding ${emojisToShow.length} emojis to grid for category: ${activeCategory}`); // Add emojis to grid with enforced styling emojisToShow.forEach(emoji => { const emojiButton = document.createElement('button'); emojiButton.className = 'emoji-button'; emojiButton.textContent = emoji; // Use textContent for better emoji handling emojiButton.title = 'Click to encode with this emoji'; emojiButton.addEventListener('click', () => { if (typeof onEmojiSelect === 'function') { onEmojiSelect(emoji); // Add visual feedback when clicked emojiButton.style.backgroundColor = '#e6f7ff'; setTimeout(() => { emojiButton.style.backgroundColor = ''; }, 300); } }); gridContainer.appendChild(emojiButton); }); container.appendChild(gridContainer); console.log('Emoji grid rendering complete'); // Add event listeners to category tabs const categoryTabButtons = container.querySelectorAll('.emoji-category-tab'); categoryTabButtons.forEach(tab => { tab.addEventListener('click', () => { // Update active tab categoryTabButtons.forEach(t => t.classList.remove('active')); tab.classList.add('active'); // Re-render the emoji grid with the selected category const selectedCategory = tab.getAttribute('data-category'); console.log('Category selected:', selectedCategory); // Determine which emojis to show let emojisToShow = []; if (selectedCategory === 'all') { // For 'all' category, combine all emojis from the categories and deduplicate Object.values(window.emojiLibrary.EMOJIS).forEach(categoryEmojis => { emojisToShow = [...emojisToShow, ...categoryEmojis]; }); // Remove duplicates using Set emojisToShow = Array.from(new Set(emojisToShow)); } else if (window.emojiLibrary.EMOJIS[selectedCategory]) { // For specific category, use emojis from that category emojisToShow = window.emojiLibrary.EMOJIS[selectedCategory]; } console.log(`Updating grid with ${emojisToShow.length} emojis for category: ${selectedCategory}`); // Clear only the grid and rebuild it gridContainer.innerHTML = ''; // Add emojis to grid emojisToShow.forEach(emoji => { const emojiButton = document.createElement('button'); emojiButton.className = 'emoji-button'; emojiButton.textContent = emoji; emojiButton.title = 'Click to encode with this emoji'; emojiButton.addEventListener('click', () => { if (typeof onEmojiSelect === 'function') { onEmojiSelect(emoji); // Add visual feedback when clicked emojiButton.style.backgroundColor = '#e6f7ff'; setTimeout(() => { emojiButton.style.backgroundColor = ''; }, 300); } }); gridContainer.appendChild(emojiButton); }); // Update the count display const countDisplay = container.querySelector('.emoji-count'); if (countDisplay) { countDisplay.textContent = `${emojisToShow.length} emojis available`; } }); }); // Debug info - add count display const countDisplay = document.createElement('div'); countDisplay.className = 'emoji-count'; countDisplay.textContent = `${emojisToShow.length} emojis available`; container.appendChild(countDisplay); };