// Puts the Panda player in Psiq Base lessons (30/10/2026). The lesson renderer leaves a placeholder with // data-panda-aula; the server only returns the embed address to logged-in users. const messages={processando:'Vídeo em processamento no Panda. Volte daqui a pouco.','sem-video':'Vídeo ainda não enviado para esta aula.',erro:'Não foi possível carregar o vídeo agora.'}; async function fill(box){ box.dataset.pandaDone='1'; const note=box.querySelector('small'); try{ const response=await fetch(`/api/aulas/${box.dataset.pandaAula}/video`,{credentials:'same-origin'}),data=await response.json().catch(()=>({})); if(!box.isConnected)return; if(response.ok&&data.status==='pronto'&&data.player.startsWith('https://')){ const frame=document.createElement('iframe'); frame.src=data.player;frame.title='Vídeo da aula';frame.allowFullscreen=true; frame.allow='accelerometer;gyroscope;autoplay;encrypted-media;picture-in-picture;fullscreen'; frame.style.cssText='display:block;width:100%;aspect-ratio:16/9;border:0;border-radius:inherit'; box.replaceWith(frame); }else if(note)note.textContent=messages[data.status]||messages.erro; }catch{if(note)note.textContent=messages.erro} } new MutationObserver(()=>document.querySelectorAll('[data-panda-aula]:not([data-panda-done])').forEach(fill)).observe(document.body,{childList:true,subtree:true});