';document.body.appendChild(ov);document.body.classList.add('pfocus');
const fr=ov.querySelector('iframe');fr.srcdoc=FLOWSRC();
const s=Math.max(r.width/innerWidth,r.height/innerHeight);ov.animate([{transform:`translate(${r.left+r.width/2-innerWidth/2}px,${r.top+r.height/2-innerHeight/2}px) scale(${s})`,borderRadius:'40px',opacity:.4},{transform:'none',borderRadius:'0px',opacity:1}],{duration:640,easing:SPR.mid});
const onMsg=ev=>{if(ev.source!==fr.contentWindow)return;const m=ev.data;
if(m.type==='ready'){fr.contentWindow.postMessage({type:'init',W:P.W,H:P.H,use:P.use,BG:P.snap?P.snap.state.BG:undefined,state:P.snap?P.snap.state:null,preset:P.snap?null:P.preset,pieces:P.snap?P.pieces.slice(P.used||0):P.pieces},'*');P.used=P.pieces.length;fr.focus();}
if(m.type==='close'){removeEventListener('message',onMsg);Object.assign(PIMG,m.imgs);P.snap=m;P.W=m.state.W;P.H=m.state.H;P.use=m.state.USE?m.state.USE[0]:P.use;pRender(P);closePaper(ov,P);}};
addEventListener('message',onMsg);}
function closePaper(ov,P){const pe=pEl(P),r=pe.getBoundingClientRect(),s=Math.max(r.width/innerWidth,r.height/innerHeight);document.body.classList.remove('pfocus');
ov.animate([{transform:'none',opacity:1},{transform:`translate(${r.left+r.width/2-innerWidth/2}px,${r.top+r.height/2-innerHeight/2}px) scale(${s})`,borderRadius:'40px',opacity:0}],{duration:520,easing:SPR.mid,fill:'forwards'}).onfinish=()=>{ov.remove();OPENP=null;pe.animate([{transform:'scale(1.05)'},{transform:'none'}],{duration:500,easing:SPR.mid});};}
})();