const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/firebase-BylMgSsD.js","assets/chunk-DT4yxi9n.js","assets/index.esm-DKdodk42.js"])))=>i.map(i=>d[i]);
import"./modulepreload-polyfill-CkedBBHh.js";import{t as e}from"./preload-helper-CT1Z6Pdu.js";import{n as t}from"./giftsCache--pqQjzkU.js";import{a as n,i as r,o as i,s as a}from"./giftMap-DhgSWgoY.js";import{r as o}from"./overlayStyle-BLOTt0xN.js";var s=document.getElementById(`frame`),c=document.getElementById(`bg`),l=document.getElementById(`items`),u=document.getElementById(`empty`),d=[],f=null,p=[];try{p=t()}catch{}var m=new Map;function h(e){return d.find(t=>t.id===e)}function g(){let e=f,t=!!e?.imageUrl;if(u.style.display=t?`none`:`flex`,e?.aspect&&s.style.setProperty(`--aspect`,String(e.aspect)),t?(c.src!==e.imageUrl&&(c.src=e.imageUrl),c.style.display=`block`):(c.removeAttribute(`src`),c.style.display=`none`),l.textContent=``,m.clear(),e)for(let t of e.items){let e=h(t.triggerId);if(!e)continue;let n=_(t,e);l.appendChild(n);let r=m.get(t.triggerId)??[];r.push(n),m.set(t.triggerId,r)}}function _(e,t){let i=n(t,p),o=document.createElement(`div`);o.className=`item`,o.style.left=`${e.xPct*100}%`,o.style.top=`${e.yPct*100}%`,o.style.setProperty(`--s`,String(e.scale));let s=document.createElement(`div`);s.className=`art`,s.style.filter=a(e.shadow);let c=r(e);if(s.style.background=c.background,s.style.borderRadius=c.borderRadius,s.style.padding=c.padding,i.imgUrl){let e=document.createElement(`img`);e.src=i.imgUrl,e.alt=``,e.decoding=`async`,s.appendChild(e)}else{let e=document.createElement(`span`);e.className=`emoji`,e.textContent=i.emoji??`🎁`,s.appendChild(e)}if(o.appendChild(s),e.showName){let t=document.createElement(`div`);t.className=`label`,t.style.fontSize=`${Math.max(9,1.1*e.scale)}vh`,t.textContent=i.name,o.appendChild(t)}return o}var v={pulse:`fire-pulse`,bounce:`fire-bounce`,glow:`fire-glow`,shake:`fire-shake`};function y(e){let t=m.get(e);if(t)for(let n of t){let t=v[f?.items.find(t=>t.triggerId===e)?.anim??`pulse`]??`fire-pulse`;n.classList.remove(`fire-pulse`,`fire-bounce`,`fire-glow`,`fire-shake`),n.offsetWidth,n.classList.add(t),window.setTimeout(()=>n.classList.remove(t),1e3)}}function b(e){e&&(Array.isArray(e.triggers)&&(d=e.triggers),f=i(e.giftMap),g())}var x=new URLSearchParams(location.search),S={green:`#00b140`,magenta:`#ff00ff`,white:`#ffffff`,black:`#000000`},C=x.get(`bg`);C&&C in S&&(document.body.style.background=S[C]);var w=x.has(`demo`),T=x.get(`uid`);try{let e=new BroadcastChannel(`oi-giftmap`);e.onmessage=e=>{let t=e.data??{};t.kind===`settings`?b({triggers:t.triggers,giftMap:t.giftMap}):t.kind===`fire`&&t.triggerId&&y(t.triggerId)}}catch{}T?e(async()=>{let{firebaseDb:e,isFirebaseConfigured:t}=await import(`./firebase-BylMgSsD.js`).then(e=>e.n);return{firebaseDb:e,isFirebaseConfigured:t}},__vite__mapDeps([0,1,2])).then(async({firebaseDb:t,isFirebaseConfigured:n})=>{if(!n())return;let{ref:r,onValue:i}=await e(async()=>{let{ref:e,onValue:t}=await import(`./index.esm-DKdodk42.js`).then(e=>e.t);return{ref:e,onValue:t}},__vite__mapDeps([2,1]));i(r(t,`rooms/${T}/state`),e=>{let t=e.val();t&&b(t)});let a=null;i(r(t,`rooms/${T}/liveEvent`),e=>{let t=e.val();if(!t?.triggerId)return;let n=t.seq??0;if(a===null){a=n;return}n!==a&&(a=n,y(t.triggerId))})}).catch(()=>{}):w||o(e=>{if(e.type===`state`)b(e);else if(e.type===`trigger_fired`){let t=e.data??{};t.triggerId&&y(t.triggerId)}});