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{t}from"./timerPresets-Dj3bOMCb.js";import{i as n,n as r,r as i,t as a}from"./overlayStyle-BLOTt0xN.js";document.documentElement.style.cssText=`background:transparent;overflow:hidden`,document.body.style.cssText=`background:transparent;margin:0;overflow:hidden;height:100vh`;var o=new URLSearchParams(location.search),s=o.has(`demo`),c=o.has(`preview`),l=document.createElement(`style`);l.textContent=`
#timer-overlay-root{width:100vw;height:100vh;display:flex;align-items:center;justify-content:center}
.oi-timer{display:flex;flex-direction:column;align-items:center;gap:10px;font-family:var(--oi-font,system-ui,sans-serif)}
.oi-desc{color:var(--oi-desc-color,var(--oi-fg2,#fff));font-size:20px;font-weight:600;text-align:center;max-width:88vw;line-height:1.25;letter-spacing:.3px;white-space:pre-line;text-shadow:var(--oi-desc-shadow,0 2px 6px rgba(0,0,0,.85),0 0 2px rgba(0,0,0,.9))}
.oi-timer-box{position:relative;background:var(--oi-bg,rgba(18,18,22,.82));border:var(--oi-border,none);border-radius:var(--oi-radius,16px);padding:var(--oi-pad,16px 30px);box-shadow:var(--oi-shadow,none);backdrop-filter:var(--oi-blur,none)}
.oi-time,.oi-led-ghost{font-size:46px;line-height:1;letter-spacing:2px;font-weight:var(--oi-weight,800);white-space:nowrap}
.oi-time{position:relative;color:var(--oi-fg,#fff);text-shadow:0 2px 4px rgba(0,0,0,.5),0 0 1px rgba(0,0,0,.5),var(--oi-glow,0 0 0 transparent),var(--oi-outline,0 0 0 transparent)}
.oi-led-ghost{position:absolute;inset:var(--oi-pad,16px 30px);color:var(--oi-fg,#fff);opacity:.1;display:none}
.oi-timer.seg7 .oi-led-ghost{display:block}
.oi-box-flash{animation:oi-tflash .45s ease}
@keyframes oi-tflash{0%{transform:scale(1)}35%{transform:scale(1.05)}100%{transform:scale(1)}}
/* Restar tiempo NO puede leerse igual que sumar: la caja se encoge y sacude en
   vez de crecer, así el espectador entiende la pérdida sin leer el badge. */
.oi-box-flash.neg{animation:oi-tflashneg .5s ease}
@keyframes oi-tflashneg{0%{transform:translateX(0) scale(1)}20%{transform:translateX(-5px) scale(.96)}45%{transform:translateX(5px) scale(.96)}70%{transform:translateX(-2px) scale(.99)}100%{transform:translateX(0) scale(1)}}
.oi-delta{position:absolute;left:50%;top:2px;font-family:var(--oi-font,system-ui,sans-serif);font-weight:800;font-size:30px;pointer-events:none;white-space:nowrap;text-shadow:0 2px 7px rgba(0,0,0,.85),0 0 3px rgba(0,0,0,.9);animation:oi-deltafly 1.1s cubic-bezier(.2,.7,.3,1) forwards}
.oi-delta.pos{color:var(--oi-add,#46f0a6)}
.oi-delta.neg{color:#ff6b6a}
@keyframes oi-deltafly{0%{opacity:0;transform:translate(-50%,10px) scale(.7)}18%{opacity:1;transform:translate(-50%,-6px) scale(1.08)}100%{opacity:0;transform:translate(-50%,-56px) scale(1)}}
/* Los dígitos NO hacen un salto fijo: durante la suma cuentan el incremento real
   (el número trepa del valor viejo al nuevo) tiñéndose verde; al restar bajan en rojo. */
.oi-time.oi-anim-up{color:var(--oi-add,#46f0a6)}
.oi-time.oi-anim-down{color:#ff6b6a}
/* Capa de efectos a pantalla completa (lluvia + tarjeta del usuario). */
.oi-fx{position:fixed;inset:0;pointer-events:none;overflow:hidden;z-index:60}
/* Cada moneda cae con tamaño, velocidad, rotación y DERIVA horizontal (--dx) propias
   → una lluvia real, no una cortina uniforme. La curva simula la aceleración de gravedad. */
.oi-coin{position:absolute;top:-12vh;will-change:transform,opacity;line-height:1;filter:drop-shadow(0 2px 3px rgba(0,0,0,.45));animation:oi-fall cubic-bezier(.33,.05,.7,1) forwards}
@keyframes oi-fall{0%{transform:translate3d(0,-12vh,0) rotate(0);opacity:0}6%{opacity:1}94%{opacity:1}100%{transform:translate3d(var(--dx,0),118vh,0) rotate(var(--r,360deg));opacity:1}}
/* Tarjeta del espectador: banner horizontal (avatar + nombre + tiempo) anclado ARRIBA
   o DEBAJO del contador. El ancla posiciona; la tarjeta solo escala/opacidad al entrar. */
.oi-fxcard-anchor{position:absolute;will-change:transform,opacity}
.oi-fxcard{display:flex;flex-direction:row;align-items:center;gap:11px;padding:7px 18px 7px 7px;border-radius:999px;background:var(--oi-card-bg,rgba(16,16,22,.88));box-shadow:0 12px 34px rgba(0,0,0,.5);backdrop-filter:blur(3px);font-family:var(--oi-font,system-ui,sans-serif);transform-origin:center;animation:oi-cardin .42s cubic-bezier(.18,.9,.28,1.2)}
.oi-fxcard .av{width:52px;height:52px;border-radius:50%;object-fit:cover;background:var(--oi-add,#46f0a6);border:2px solid var(--oi-add,#46f0a6);box-shadow:0 0 0 4px rgba(70,240,166,.18);display:flex;align-items:center;justify-content:center;font-weight:900;font-size:24px;color:#0a1410;overflow:hidden;flex:none}
.oi-fxcard .nm{color:#fff;font-weight:800;font-size:20px;letter-spacing:.3px;text-shadow:0 2px 6px rgba(0,0,0,.75);max-width:46vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.oi-fxcard .pl{color:var(--oi-add,#46f0a6);font-weight:900;font-size:26px;line-height:1;text-shadow:0 2px 9px rgba(0,0,0,.6);flex:none}
.oi-fxcard-anchor.out .oi-fxcard{animation:oi-cardout .42s ease forwards}
@keyframes oi-cardin{0%{opacity:0;transform:scale(.55)}60%{opacity:1;transform:scale(1.06)}100%{opacity:1;transform:scale(1)}}
@keyframes oi-cardout{to{opacity:0;transform:scale(.9)}}
${a}
`,document.head.appendChild(l);var u=document.getElementById(`timer-overlay-root`);u.innerHTML=`
  <div class="oi-timer" id="timer">
    <div class="oi-desc" id="desc"></div>
    <div class="oi-timer-box" id="box">
      <div class="oi-led-ghost" id="ghost"></div>
      <div class="oi-time" id="time"></div>
    </div>
  </div>`;var d=document.getElementById(`timer`),f=document.getElementById(`desc`),p=document.getElementById(`ghost`),m=document.getElementById(`time`),h=document.getElementById(`box`);function g(e){let t=e>0?`+`:`-`,n=Math.abs(e);if(n<1e3)return`${t}${(n/1e3).toFixed(1)}s`;let r=Math.round(n/1e3);if(r<60)return`${t}${r}s`;let i=Math.floor(r/60),a=r%60;return a?`${t}${i}m${a}s`:`${t}${i}m`}function _(e){if(!e)return;let t=document.createElement(`div`);t.className=`oi-delta `+(e>0?`pos`:`neg`),t.textContent=g(e),h.appendChild(t),h.classList.remove(`oi-box-flash`,`neg`),h.offsetWidth,h.classList.add(`oi-box-flash`),e<0&&h.classList.add(`neg`),setTimeout(()=>t.remove(),1150)}var v=!1,y=0,b=0,x=`extendable`,S=``,C=10,w=1,T=null,E={rain:!0,digits:!0,user:!0,pos:`above`,minCoins:0,amount:`med`,durationMs:2800},D={...E};function O(e){D={...E,...e??{}}}var k={low:14,med:26,high:44},A=!1,j=0,M=0,N=850,P=document.createElement(`div`);P.className=`oi-fx`,document.body.appendChild(P);function F(){let e=k[D.amount]??k.med,t=document.createDocumentFragment(),n=0;for(let r=0;r<e;r++){let e=document.createElement(`div`);e.className=`oi-coin`,e.textContent=`🪙`;let r=14+Math.round(Math.random()*32),i=1.4+Math.random()*1.7,a=Math.random()*1.1;e.style.left=Math.random()*100+`vw`,e.style.fontSize=r+`px`,e.style.opacity=String(.7+Math.random()*.3),e.style.animationDuration=i+`s`,e.style.animationDelay=a+`s`,e.style.setProperty(`--dx`,Math.random()*44-22+`vw`),e.style.setProperty(`--r`,Math.random()*1080-540+`deg`),t.appendChild(e);let o=(i+a+.3)*1e3;n=Math.max(n,o),setTimeout(()=>e.remove(),o)}return P.appendChild(t),n}function I(e,t,n){let r=document.createElement(`div`);r.className=`oi-fxcard`;let i=document.createElement(`div`);if(i.className=`av`,t){let n=document.createElement(`img`);n.src=t,n.alt=``,n.className=`av`,n.onerror=()=>{n.replaceWith(i),i.textContent=(e[0]||`★`).toUpperCase()},r.appendChild(n)}else i.textContent=(e[0]||`★`).toUpperCase(),r.appendChild(i);let a=document.createElement(`div`);a.className=`nm`,a.textContent=e;let o=document.createElement(`div`);o.className=`pl`,o.textContent=g(n),r.append(a,o);let s=document.createElement(`div`);s.className=`oi-fxcard-anchor`,s.appendChild(r);let c=h.getBoundingClientRect(),l=c.left+c.width/2;s.style.left=l+`px`,D.pos===`below`?(s.style.top=c.bottom+16+`px`,s.style.transform=`translate(-50%,0)`):(s.style.top=c.top-16+`px`,s.style.transform=`translate(-50%,-100%)`),P.appendChild(s),setTimeout(()=>{s.classList.add(`out`),setTimeout(()=>s.remove(),440)},Math.max(800,D.durationMs))}function L(e){A=!0,j=Date.now(),M=e,m.classList.remove(`oi-anim-up`,`oi-anim-down`),m.classList.add(e>=0?`oi-anim-up`:`oi-anim-down`),J()}function R(e,t){if(!e)return;D.digits?L(e):J(),_(e);let n=Number(t?.coins??0);e>0&&D.rain&&n>0&&n>=(D.minCoins||0)&&(F(),D.user&&t?.nickname&&I(t.nickname,t.avatar,e))}function z(){D.digits&&L(3e4),D.rain&&(F(),D.user&&I(`Viewer estrella`,null,3e4))}function B(){let e=Number.isInteger(C)?String(C):C.toFixed(1);return`${w>0?w:1} 🪙 = +${e}s`}function V(){return S.trim()||B()}function H(e){return t.find(t=>t.id===e)??t.find(e=>e.id===`pro`)}function U(e,t){let i=r(u,H(e),t);d.classList.toggle(`seg7`,i===`seg7`),n(p,`88:88:88`,8)}function W(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=e=>String(e).padStart(2,`0`);return`${a(n)}:${a(r)}:${a(i)}`}var G=``;function K(){let e=v?y-Date.now():b;if(A){let t=Math.min(1,(Date.now()-j)/N),n=1-(1-t)*(1-t);e-=M*(1-n),t>=1&&(A=!1,m.classList.remove(`oi-anim-up`,`oi-anim-down`))}let t=W(e);t!==G&&(n(m,t,8),G=t);let r=x===`extendable`?V():``;f.style.display=r?`block`:`none`,f.textContent=r}function q(){K(),v&&y-Date.now()>0||A?T=requestAnimationFrame(q):(T=null,v&&y-Date.now()<=0&&(v=!1,b=0),K())}function J(){K(),(v||A)&&T==null&&(T=requestAnimationFrame(q))}function Y(e){v=!!e.running,y=e.endsAtUtc??0,b=e.remainingMs??0,c||(e.mode&&(x=e.mode),S=e.description??S,e.giftSeconds!=null&&(C=e.giftSeconds),e.giftPerCoins!=null&&(w=e.giftPerCoins)),J()}var X=o.get(`uid`);if(X)U(`pro`),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/${X}/settings`),e=>{let t=e.val(),n=t?.global?.timer??t?.tiktok?.timer;n&&(U(n.preset,n.vars),O(n.fx))}),i(r(t,`rooms/${X}/timerState`),e=>{let t=e.val();t&&Y(t)});let a=!0;i(r(t,`rooms/${X}/timerEvent`),e=>{let t=e.val();if(a){a=!1;return}t?.deltaMs&&R(t.deltaMs,t)})}).catch(()=>{});else if(s){U(o.get(`preset`)??void 0,Z(o.get(`vars`))),S=o.get(`desc`)??``,x=o.get(`mode`)??`extendable`,C=Number(o.get(`gs`)??`10`),w=Number(o.get(`gp`)??`1`),v=!0,y=Date.now()+296e3,J();let e=0;setInterval(()=>{let t=++e%3==0,n=t?-5e3:1e4;y+=n,t?R(n):R(n,{coins:10,nickname:`Viewer estrella`})},4e3)}else U(`pro`),c&&window.addEventListener(`message`,e=>{if(e.origin!==window.location.origin)return;let t=e.data;if(t?.type===`oi-timer-fx-demo`){z();return}t?.type===`oi-timer-preview`&&(U(t.preset,t.vars),O(t.fx),S=t.desc??``,t.mode&&(x=t.mode),typeof t.gs==`number`&&(C=t.gs),typeof t.gp==`number`&&(w=t.gp),K())}),i(e=>{if(e.type===`timer_state`&&e.data)Y(e.data);else if(e.type===`timer_added`&&e.data){let t=e.data;R(t.deltaMs,t)}else if(e.type===`settings`&&!c){let t=e.timer;t&&typeof t==`object`&&(U(t.preset,t.vars),O(t.fx))}}),fetch(`/api/timer`).then(e=>e.json()).then(e=>{e?.config&&!c&&(x=e.config.mode??x,S=e.config.description??S),e?.state&&Y(e.state)}).catch(()=>{}),c||fetch(`/api/overlay/settings?platform=`+(o.get(`platform`)??`tiktok`)).then(e=>e.json()).then(e=>{e?.timer&&(U(e.timer.preset,e.timer.vars),O(e.timer.fx))}).catch(()=>{});function Z(e){if(e)try{return JSON.parse(decodeURIComponent(escape(atob(e))))}catch{return}}