(function(){
var eagAudioUnlocked=false;
var eagVoiceCache=[];
var eagSpeechRetryTimer=null;
function safeParseJSON(text){ try{return JSON.parse(text||'{}');}catch(e){return{};}}
function difficultyRank(level){ return level==='hard' ? 3:level==='medium' ? 2:1; }
function loadVoices(){
try{
if(!('speechSynthesis' in window)) return [];
eagVoiceCache=window.speechSynthesis.getVoices()||[];
return eagVoiceCache;
}catch(e){ return []; }}
function primeSafariAudio(){
try{
loadVoices();
var Ctx=window.AudioContext||window.webkitAudioContext;
if(Ctx){
var ctx=tone.ctx||(tone.ctx=new Ctx());
if(ctx&&ctx.state==='suspended'&&typeof ctx.resume==='function') ctx.resume();
}
eagAudioUnlocked=true;
}catch(e){}}
function getBestVoice(voiceCode){
var voices=eagVoiceCache&&eagVoiceCache.length ? eagVoiceCache:loadVoices();
if(!voices||!voices.length) return null;
var target=String(voiceCode||'en-GB').toLowerCase();
var primary=voices.find(function(v){ return (v.lang||'').toLowerCase()===target; });
if(primary) return primary;
var fallback=voices.find(function(v){ return (v.lang||'').toLowerCase().indexOf(target)===0; });
if(fallback) return fallback;
var english=voices.find(function(v){ return (v.lang||'').toLowerCase().indexOf('en')===0; });
return english||null;
}
function speak(text, voiceCode, attempt){
try{
if(!('speechSynthesis' in window)) return;
var phrase=String(text||'').trim();
if(!phrase) return;
if(eagSpeechRetryTimer){ clearTimeout(eagSpeechRetryTimer); eagSpeechRetryTimer=null; }
primeSafariAudio();
var synth=window.speechSynthesis;
var voice=getBestVoice(voiceCode||'en-GB');
if((!voice||!eagVoiceCache.length)&&(attempt||0) < 2){
eagSpeechRetryTimer=window.setTimeout(function(){ speak(phrase, voiceCode, (attempt||0) + 1); }, 120);
loadVoices();
return;
}
synth.cancel();
var u=new SpeechSynthesisUtterance(phrase);
u.lang=voiceCode||'en-GB';
if(voice) u.voice=voice;
u.rate=0.95;
u.pitch=1;
window.setTimeout(function(){
try{ synth.speak(u); }catch(e){}}, 30);
}catch(e){}}
function tone(type){
try{
var Ctx=window.AudioContext||window.webkitAudioContext;
if(!Ctx) return;
var ctx=tone.ctx||(tone.ctx=new Ctx());
if(ctx&&ctx.state==='suspended'&&typeof ctx.resume==='function') ctx.resume();
var now=ctx.currentTime;
var notes=type==='win' ? [523.25,659.25,783.99]:type==='finish' ? [523.25,659.25,783.99,1046.5]:type==='boss' ? [392,523.25,659.25,880]:[240,180];
notes.forEach(function(freq,i){
var osc=ctx.createOscillator();
var gain=ctx.createGain();
osc.type=type==='bad' ? 'triangle':'sine';
osc.frequency.value=freq;
gain.gain.setValueAtTime(0.0001, now + i*0.05);
gain.gain.exponentialRampToValueAtTime(type==='bad' ? 0.045:0.065, now + i*0.05 + 0.01);
gain.gain.exponentialRampToValueAtTime(0.0001, now + i*0.05 + 0.2);
osc.connect(gain); gain.connect(ctx.destination);
osc.start(now + i*0.05); osc.stop(now + i*0.05 + 0.22);
});
}catch(e){}}
function confetti(root){
var layer=root.querySelector('.emh-eag-confetti');
if(!layer) return;
layer.innerHTML='';
var colors=['#ff5ea8','#ffd84d','#7c5cff','#39d3ff','#2bd67b','#ff8c42'];
for(var i=0;i<36;i++){
var piece=document.createElement('span');
piece.className='emh-eag-confetti-piece';
piece.style.left=(Math.random()*100).toFixed(2)+'%';
piece.style.background=colors[i % colors.length];
piece.style.transform='translateY(-20px) rotate(' + Math.round(Math.random()*360) + 'deg)';
piece.style.animationDelay=(Math.random()*0.12).toFixed(2)+'s';
piece.style.animationDuration=(0.9 + Math.random()*0.8).toFixed(2)+'s';
layer.appendChild(piece);
}
setTimeout(function(){ layer.innerHTML=''; }, 2200);
}
function renderMap(root, state){
var map=root.querySelector('.emh-eag-level-map');
if(!map) return;
var total=Math.max(1, state.cards.length||1);
var html='';
for(var i=0;i<total;i++){
var card=state.cards[i]||{};
var cls='emh-eag-level';
if(i < state.index) cls +=' is-done';
else if(i===state.index&&state.index < total) cls +=' is-current';
if(card.isBoss) cls +=' is-boss';
if(i===total-1) cls +=' is-goal';
var icon=card.isBoss ? '👑':(i===total-1?'🏰':'⭐');
html +='<span class="'+cls+'"><span class="emh-eag-level-inner">'+icon+'</span></span>';
if(i < total-1) html +='<span class="emh-eag-level-link"></span>';
}
map.innerHTML=html;
}
function renderLeaderboard(root, board, page, perPage){
var list=root.querySelector('.emh-eag-leaderboard');
var pager=root.querySelector('.emh-eag-leaderboard-pager');
if(!list) return;
board=Array.isArray(board) ? board:[];
perPage=Math.max(1, Number(perPage||5));
var totalPages=Math.max(1, Math.ceil(board.length / perPage));
page=Math.max(1, Math.min(Number(page||1), totalPages));
if(!board.length){
list.innerHTML='<li class="emh-eag-board-empty">No scores yet. Be the first star explorer!</li>';
if(pager) pager.innerHTML='';
return;
}
var start=(page - 1) * perPage;
var slice=board.slice(start, start + perPage);
list.innerHTML=slice.map(function(item, idx){
return '<li><span class="place">#'+(start + idx + 1)+'</span><span class="name">'+escapeHtml(item.player||'Player')+'</span><span class="score">⭐ '+Number(item.stars||0)+' · 🏆 '+Number(item.badges||0)+' · '+Number(item.score||0)+' pts</span></li>';
}).join('');
if(pager){
var prevDisabled=page <=1 ? ' disabled aria-disabled="true"':'';
var nextDisabled=page >=totalPages ? ' disabled aria-disabled="true"':'';
pager.innerHTML='<button type="button" class="emh-eag-board-btn emh-eag-board-prev"'+prevDisabled+'><span aria-hidden="true">←</span><span class="emh-eag-board-btn-text">Previous</span></button><span class="emh-eag-board-page">Page '+page+' of '+totalPages+'</span><button type="button" class="emh-eag-board-btn emh-eag-board-next"'+nextDisabled+'><span class="emh-eag-board-btn-text">Next</span><span aria-hidden="true">→</span></button>';
var prev=pager.querySelector('.emh-eag-board-prev');
var next=pager.querySelector('.emh-eag-board-next');
if(prev) prev.addEventListener('click', function(){ if(page>1){ root.__eagBoardPage=page - 1; renderLeaderboard(root, board, root.__eagBoardPage, perPage); }});
if(next) next.addEventListener('click', function(){ if(page<totalPages){ root.__eagBoardPage=page + 1; renderLeaderboard(root, board, root.__eagBoardPage, perPage); }});
}}
function escapeHtml(str){
return String(str||'').replace(/[&<>"']/g, function(ch){ return ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#039;'})[ch]; });
}
function storageKey(suffix){ return 'emh_eag_' + suffix; }
function safeStorageGet(key){
try{ return window.localStorage ? window.localStorage.getItem(key):''; }catch(e){ return ''; }}
function safeStorageSet(key, value){
try{ if(window.localStorage) window.localStorage.setItem(key, value); }catch(e){}}
function getViewportSize(){
var vv=window.visualViewport;
var vw=vv&&vv.width ? vv.width:window.innerWidth;
var vh=vv&&vv.height ? vv.height:window.innerHeight;
return { width: Math.max(320, Math.round(vw||0)), height: Math.max(320, Math.round(vh||0)) };}
function clearFullscreenFit(root){
var wrap=root&&root.parentElement ? root.parentElement:null;
if(!wrap) return;
wrap.classList.remove('emh-eag-fit-fullscreen');
wrap.classList.remove('emh-eag-no-scale-fullscreen');
root.style.transform='';
root.style.transformOrigin='';
root.style.width='';
root.style.maxWidth='';
root.style.maxHeight='';
root.style.margin='';
}
function globalFullscreenActive(){
return !!(document.fullscreenElement||document.webkitFullscreenElement||document.msFullscreenElement);
}
function applyFullscreenFit(root){
var wrap=root&&root.parentElement ? root.parentElement:null;
if(!wrap) return;
var active=wrap.classList.contains('emh-eag-fallback-fullscreen')||globalFullscreenActive();
if(!active){ clearFullscreenFit(root); return; }
var size=getViewportSize();
var coarse=window.matchMedia&&window.matchMedia('(pointer: coarse)').matches;
var noScaleMode=coarse||size.width <=1024||size.height <=820;
if(noScaleMode){
wrap.classList.add('emh-eag-fit-fullscreen');
wrap.classList.add('emh-eag-no-scale-fullscreen');
root.style.transform='none';
root.style.transformOrigin='top center';
root.style.width='100%';
root.style.maxWidth='none';
root.style.maxHeight='none';
root.style.margin='0';
return;
}
wrap.classList.remove('emh-eag-no-scale-fullscreen');
wrap.classList.add('emh-eag-fit-fullscreen');
root.style.transform='none';
root.style.width='100%';
root.style.maxWidth='none';
root.style.maxHeight='none';
var baseW=Math.max(root.scrollWidth||size.width, 640);
var baseH=Math.max(root.scrollHeight||size.height, 420);
var scale=Math.min(size.width / baseW, size.height / baseH, 1);
if(size.width > size.height&&size.height < 520){
scale=Math.min(scale, 0.92);
}
if(!isFinite(scale)||scale <=0) scale=1;
root.style.width=baseW + 'px';
root.style.maxWidth='none';
root.style.margin='0 auto';
root.style.transformOrigin='top center';
root.style.transform='scale(' + scale + ')';
}
function updateViewportSizing(root){
var wrap=root&&root.parentElement ? root.parentElement:null;
if(!wrap) return;
var size=getViewportSize();
var vh=size.height * 0.01;
wrap.style.setProperty('--emh-eag-app-vh', vh + 'px');
var compact=size.height < 820||size.width < 1180||(wrap.classList.contains('emh-eag-fallback-fullscreen')&&size.width < 900);
root.classList.toggle('is-compact', !!compact);
root.classList.toggle('is-landscape', size.width > size.height);
applyFullscreenFit(root);
}
function init(root){
var cfgEl=root.querySelector('.emh-eag-config');
if(!cfgEl) return;
var cfg=safeParseJSON(cfgEl.textContent);
var settings=cfg.settings||{};
var initial=cfg.initialGame&&Array.isArray(cfg.initialGame.cards) ? cfg.initialGame:{cards:[]};
var state={
cards: initial.cards||[],
index: 0,
stars: 0,
badges: 0,
answered: false,
correctStreak: 0,
seenIds: [],
player: '',
device: safeStorageGet(storageKey('device'))||('eag' + Math.random().toString(36).slice(2) + Date.now().toString(36)),
board: Array.isArray(cfg.leaderboard) ? cfg.leaderboard:[],
boardPerPage: Number(cfg.leaderboardPerPage||5)
};
safeStorageSet(storageKey('device'), state.device);
root.__eagBoardPage=1;
var totalEl=root.querySelector('.emh-eag-total');
var roundEl=root.querySelector('.emh-eag-round');
var starsEl=root.querySelector('.emh-eag-stars');
var badgesEl=root.querySelector('.emh-eag-badges');
var catEl=root.querySelector('.emh-eag-category');
var targetEl=root.querySelector('.emh-eag-target-word');
var optionsEl=root.querySelector('.emh-eag-options');
var feedbackEl=root.querySelector('.emh-eag-feedback');
var nextBtn=root.querySelector('.emh-eag-next');
var playAgainBtn=root.querySelector('.emh-eag-play-again');
var listenBtn=root.querySelector('.emh-eag-listen');
var playerInput=root.querySelector('.emh-eag-player-name');
var fullscreenBtn=root.querySelector('.emh-eag-fullscreen');
function setPlayerValue(name){
state.player=String(name||'').trim()||generateAutoPlayerName();
safeStorageSet(storageKey('player'), state.player);
if(playerInput) playerInput.value=state.player;
}
function current(){ return state.cards[state.index]||null; }
function hashString(str){
var hash=0;
str=String(str||'');
for(var i=0;i<str.length;i++) hash=((hash << 5) - hash + str.charCodeAt(i)) | 0;
return Math.abs(hash);
}
function generateAutoPlayerName(){
var saved=safeStorageGet(storageKey('player'))||'';
if(/^Player\d{4,8}$/i.test(saved)) return saved;
var num=1000 + (hashString(state.device||Date.now()) % 9000);
return 'Player' + String(num);
}
function savePlayerName(){
setPlayerValue(generateAutoPlayerName());
}
function loadSavedClientProgress(){
setPlayerValue(generateAutoPlayerName());
}
function isFullscreenActive(){
return !!(document.fullscreenElement||document.webkitFullscreenElement||document.msFullscreenElement);
}
function updateFullscreenButton(){
if(!fullscreenBtn) return;
var wrap=root&&root.parentElement ? root.parentElement:root;
var active=isFullscreenActive()||wrap.classList.contains('emh-eag-fallback-fullscreen');
fullscreenBtn.setAttribute('aria-pressed', active ? 'true':'false');
fullscreenBtn.textContent=active ? '⤢ Exit Full Screen':'⛶ Full Screen';
}
function enterFallbackFullscreen(){
var wrap=root&&root.parentElement ? root.parentElement:root;
wrap.classList.add('emh-eag-fallback-fullscreen');
document.documentElement.classList.add('emh-eag-html-fullscreen');
document.body.classList.add('emh-eag-body-fullscreen');
updateViewportSizing(root);
updateFullscreenButton();
window.setTimeout(function(){ updateViewportSizing(root); }, 180);
}
function exitFallbackFullscreen(){
var wrap=root&&root.parentElement ? root.parentElement:root;
wrap.classList.remove('emh-eag-fallback-fullscreen');
document.documentElement.classList.remove('emh-eag-html-fullscreen');
document.body.classList.remove('emh-eag-body-fullscreen');
clearFullscreenFit(root);
updateViewportSizing(root);
updateFullscreenButton();
}
function shouldUseFallbackFullscreen(){
var ua=navigator.userAgent||'';
var coarse=window.matchMedia&&window.matchMedia('(pointer: coarse)').matches;
return coarse||/iPhone|iPad|iPod|Android/i.test(ua);
}
function toggleFullscreen(){
var wrap=root&&root.parentElement ? root.parentElement:root;
if(isFullscreenActive()){
if(document.exitFullscreen) document.exitFullscreen();
else if(document.webkitExitFullscreen) document.webkitExitFullscreen();
else exitFallbackFullscreen();
return;
}
if(wrap.classList.contains('emh-eag-fallback-fullscreen')){
exitFallbackFullscreen();
return;
}
if(shouldUseFallbackFullscreen()){
enterFallbackFullscreen();
return;
}
try{
if(wrap.requestFullscreen) wrap.requestFullscreen().catch(function(){ enterFallbackFullscreen(); });
else if(wrap.webkitRequestFullscreen) wrap.webkitRequestFullscreen();
else if(wrap.msRequestFullscreen) wrap.msRequestFullscreen();
else enterFallbackFullscreen();
}catch(e){ enterFallbackFullscreen(); }
window.setTimeout(function(){ updateViewportSizing(root); updateFullscreenButton(); }, 180);
}
function adaptiveAdjust(currentCorrect){
if(!settings.enable_adaptive) return;
var nextIndex=state.index + 1;
if(nextIndex >=state.cards.length) return;
var desired=currentCorrect ? (state.correctStreak >=2 ? 3:2):1;
var swapIndex=-1;
for(var i=nextIndex;i<state.cards.length;i++){
var rank=Number(state.cards[i].difficultyRank||difficultyRank((state.cards[i].target||{}).difficulty));
if(currentCorrect&&rank >=desired){ swapIndex=i; break; }
if(!currentCorrect&&rank <=desired){ swapIndex=i; break; }}
if(swapIndex > nextIndex){
var temp=state.cards[nextIndex];
state.cards[nextIndex]=state.cards[swapIndex];
state.cards[swapIndex]=temp;
}}
function render(){
updateViewportSizing(root);
totalEl.textContent=state.cards.length||0;
roundEl.textContent=state.cards.length ? Math.min(state.index + 1, state.cards.length):0;
starsEl.textContent=state.stars;
badgesEl.textContent=state.badges;
renderMap(root, state);
renderLeaderboard(root, state.board, root.__eagBoardPage||1, state.boardPerPage);
var c=current();
optionsEl.innerHTML='';
feedbackEl.textContent='';
feedbackEl.className='emh-eag-feedback';
state.answered=false;
nextBtn.hidden=false;
playAgainBtn.hidden=true;
if(!c){
targetEl.textContent='';
catEl.textContent='Adventure complete!';
feedbackEl.textContent='Amazing! You finished the rainbow adventure!';
feedbackEl.classList.add('ok');
nextBtn.hidden=true;
playAgainBtn.hidden=false;
roundEl.textContent=state.cards.length||0;
tone('finish');
confetti(root);
saveProgress();
return;
}
targetEl.textContent=c.target.word||'';
catEl.textContent=c.isBoss ? '👑 Mini Boss Level':(c.target.category ? ('Category: ' + c.target.category):'Find the picture');
optionsEl.classList.toggle('is-boss', !!c.isBoss);
(c.options||[]).forEach(function(opt){
var btn=document.createElement('button');
btn.type='button';
btn.className='emh-eag-option';
btn.setAttribute('data-id', opt.id);
btn.setAttribute('aria-label', String(opt.word||'option'));
btn.innerHTML='<div class="emh-eag-option-media"><img loading="eager" decoding="async" alt="'+escapeHtml(String(opt.word||'picture'))+'" src="'+String(opt.image||'').replace(/"/g,'&quot;')+'"></div><span class="emh-eag-tap-sound">🔊 Tap to hear</span>';
var img=btn.querySelector('img');
if(img){
img.addEventListener('error', function(){
if(this.dataset.fallbackApplied==='1') return;
this.dataset.fallbackApplied='1';
this.src='data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNTYwIiB2aWV3Qm94PSIwIDAgODAwIDU2MCI+PHJlY3Qgd2lkdGg9IjgwMCIgaGVpZ2h0PSI1NjAiIHJ4PSI1NiIgZmlsbD0iI2YzZjZmZiIvPjx0ZXh0IHg9IjQwMCIgeT0iMjg1IiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmb250LXNpemU9IjExMCI+8J+WvDwvdGV4dD48L3N2Zz4=';
});
}
btn.addEventListener('click', function(){
speak(opt.word, settings.voice||'en-GB');
choose(opt, btn);
});
optionsEl.appendChild(btn);
});
}
function choose(opt, btn){
if(state.answered) return;
var c=current(); if(!c) return;
state.answered=true;
var correctId=c.target.id;
Array.prototype.slice.call(optionsEl.querySelectorAll('.emh-eag-option')).forEach(function(el){
var id=parseInt(el.getAttribute('data-id'),10);
if(id===correctId) el.classList.add('is-correct');
});
if(opt.id===correctId){
btn.classList.add('is-correct');
state.correctStreak +=1;
state.stars +=Number(c.rewardStars||1);
if(state.stars > 0&&state.stars % 4===0) state.badges +=1;
starsEl.textContent=state.stars;
badgesEl.textContent=state.badges;
feedbackEl.textContent=c.isBoss ? 'Super! Boss level cleared!':('Wonderful! You found ' + String(c.target.word||'').toUpperCase() + '! Listen and say it again!');
feedbackEl.classList.add('ok');
tone(c.isBoss ? 'boss':'win');
confetti(root);
setTimeout(function(){ speak(c.target.word, settings.voice||'en-GB'); }, 120);
adaptiveAdjust(true);
}else{
btn.classList.add('is-wrong');
state.correctStreak=0;
feedbackEl.textContent='Nice try! You heard ' + String(opt.word||'').toUpperCase() + '. Tap Next for another adventure.';
feedbackEl.classList.add('bad');
tone('bad');
adaptiveAdjust(false);
}
if(settings.enable_progress){
safeStorageSet(storageKey('progress'), JSON.stringify({stars: state.stars, badges: state.badges, levels: state.index + 1}));
}}
function next(){
var c=current();
if(c&&c.target&&c.target.id) state.seenIds.push(c.target.id);
if(state.index < state.cards.length - 1){
state.index +=1;
render();
}else{
state.index=state.cards.length;
render();
}}
function fetchNewGame(){
try{ if('speechSynthesis' in window) window.speechSynthesis.cancel(); }catch(e){}
var fd=new FormData();
fd.append('action','emh_eag_new_game');
fd.append('nonce', cfg.nonce||'');
fd.append('_ts', String(Date.now()));
(state.seenIds||[]).forEach(function(id){ fd.append('exclude[]', id); });
fetch(cfg.ajax_url, {method:'POST', body:fd, credentials:'same-origin', cache:'no-store', headers:{'X-Requested-With':'XMLHttpRequest','Cache-Control':'no-cache, no-store, must-revalidate','Pragma':'no-cache'}})
.then(function(r){ return r.json(); })
.then(function(json){
if(json&&json.success&&json.data&&Array.isArray(json.data.cards)){
state.cards=json.data.cards;
state.index=0;
state.stars=0;
state.badges=0;
state.answered=false;
state.correctStreak=0;
render();
}}).catch(function(){ render(); });
}
function saveProgress(){
setPlayerValue(generateAutoPlayerName());
var fd=new FormData();
fd.append('action','emh_eag_save_progress');
fd.append('nonce', cfg.nonce||'');
fd.append('player', state.player||'Player');
fd.append('device', state.device||'');
fd.append('stars', String(state.stars||0));
fd.append('badges', String(state.badges||0));
fd.append('levels', String(state.cards.length||0));
fetch(cfg.ajax_url, {method:'POST', body:fd, credentials:'same-origin', cache:'no-store', headers:{'X-Requested-With':'XMLHttpRequest','Cache-Control':'no-cache, no-store, must-revalidate','Pragma':'no-cache'}})
.then(function(r){ return r.json(); })
.then(function(json){
if(json&&json.success&&json.data&&Array.isArray(json.data.leaderboard)){
state.board=json.data.leaderboard;
renderLeaderboard(root, state.board, root.__eagBoardPage||1, state.boardPerPage);
}}).catch(function(){});
}
if(playerInput){ playerInput.setAttribute('readonly', 'readonly'); playerInput.addEventListener('focus', function(){ this.blur(); });setPlayerValue(generateAutoPlayerName()); }
if(fullscreenBtn){ fullscreenBtn.addEventListener('click', toggleFullscreen); }
if(listenBtn){ listenBtn.addEventListener('click', function(){ var c=current(); if(c&&c.target) speak(c.target.word, settings.voice||'en-GB'); });}
if(nextBtn){ nextBtn.addEventListener('click', next); }
if(playAgainBtn){ playAgainBtn.addEventListener('click', fetchNewGame); }
try{ updateViewportSizing(root); }catch(e){}
window.addEventListener('resize', function(){ try{ updateViewportSizing(root); }catch(e){} updateFullscreenButton(); });
window.addEventListener('orientationchange', function(){ try{ updateViewportSizing(root); }catch(e){} updateFullscreenButton(); });
if(window.visualViewport){
window.visualViewport.addEventListener('resize', function(){ try{ updateViewportSizing(root); }catch(e){} updateFullscreenButton(); });
window.visualViewport.addEventListener('scroll', function(){ try{ updateViewportSizing(root); }catch(e){} updateFullscreenButton(); });
}
document.addEventListener('fullscreenchange', function(){ try{ updateViewportSizing(root); }catch(e){} updateFullscreenButton(); });
document.addEventListener('webkitfullscreenchange', function(){ try{ updateViewportSizing(root); }catch(e){} updateFullscreenButton(); });
loadSavedClientProgress();
updateFullscreenButton();
render();
}
['touchstart','touchend','mousedown','keydown','click'].forEach(function(evt){
document.addEventListener(evt, primeSafariAudio, {passive:true});
});
if('speechSynthesis' in window){
loadVoices();
if(typeof window.speechSynthesis.onvoiceschanged!=='undefined'){
window.speechSynthesis.onvoiceschanged=loadVoices;
}}
document.addEventListener('visibilitychange', function(){
if(document.visibilityState==='visible') primeSafariAudio();
});
document.addEventListener('DOMContentLoaded', function(){
var roots=document.querySelectorAll('[data-eag-root="1"]');
Array.prototype.forEach.call(roots, init);
});
})();