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"./tiktokGifts-DfCadSx2.js";import{t as n}from"./musicPresets-gIjIkHVZ.js";import{n as r,r as i}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 a=new URLSearchParams(location.search),o=a.has(`demo`),s=a.get(`uid`),c=document.createElement(`style`);c.textContent=`
#music-gifts-overlay-root{width:100vw;height:100vh;display:flex;align-items:center;padding:6px;box-sizing:border-box}
.oi-mg{font-family:var(--oi-font,system-ui,sans-serif);background:var(--oi-bg,rgba(18,18,24,.72));
  border:var(--oi-border,none);border-radius:var(--oi-radius,14px);padding:var(--oi-pad,10px 14px);
  box-shadow:var(--oi-shadow,none);backdrop-filter:var(--oi-blur,none);max-width:calc(100vw - 12px);
  display:flex;flex-direction:column;gap:8px}
.oi-mg-title{color:var(--oi-fg,#fff);font-weight:var(--oi-weight,700);font-size:15px;letter-spacing:.3px}
.oi-mg-grid{display:grid;gap:6px 14px}
.oi-mg-row{display:flex;align-items:center;gap:8px;min-width:0}
.oi-mg-img{width:26px;height:26px;object-fit:contain;flex:0 0 auto}
.oi-mg-badge{min-width:26px;height:26px;border-radius:7px;background:var(--oi-accent,#ff2d6f);color:#fff;
  font-size:11px;font-weight:800;display:flex;align-items:center;justify-content:center;padding:0 5px;flex:0 0 auto}
.oi-mg-name{color:var(--oi-fg,#fff);font-size:13px;font-weight:600;white-space:nowrap}
.oi-mg-coins{color:var(--oi-fg2,rgba(255,255,255,.65));font-size:11px;font-weight:600;white-space:nowrap}
.oi-mg-text{color:var(--oi-fg2,rgba(255,255,255,.72));font-size:12.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.oi-mg-sep{height:1px;background:rgba(255,255,255,.14);margin:2px 0}
.oi-mg-cmd{display:flex;align-items:center;gap:7px}
.oi-mg-code{background:rgba(255,255,255,.12);border-radius:5px;padding:1px 6px;color:var(--oi-fg,#fff);
  font-size:11.5px;font-weight:700}
.oi-mg.hidden{display:none}
`,document.head.appendChild(c);var l=document.getElementById(`music-gifts-overlay-root`);l.innerHTML=`<div class="oi-mg hidden" id="card"></div>`;var u=document.getElementById(`card`),d={title:``,showChatCommands:!0,showCoins:!0,columns:1,align:`center`},f=[],p=[],m={request:()=>`Pide tu canción`,boost:e=>`Sube ${Math.max(1,e.amount)} puesto${Math.max(1,e.amount)>1?`s`:``}`,top:()=>`Pasa al primer puesto`,skip:()=>`Salta la canción`},h={request:`pedir canción`,position:`ver tu puesto`,revoke:`quitar la tuya`,skip:`saltar`};function g(e){return n.find(t=>t.id===e)??n.find(e=>e.id===`pro`)}function _(e){if(e.minCoins>0)return{name:`Desde ${e.minCoins}`,coins:void 0};let n=t.find(t=>t.id===e.giftId)??t.find(t=>t.name===e.giftName);return{img:n?.imgUrl,name:n?.name??e.giftName??`?`,coins:n?.coins}}function v(e){return e.replace(/[&<>"]/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e])}function y(){let e=f.filter(e=>e.enabled),t=d.showChatCommands===!1?[]:p.filter(e=>e.enabled&&e.triggers?.length),n=e.length===0&&t.length===0;if(u.classList.toggle(`hidden`,n),n)return;let r=Math.max(1,Math.min(3,d.columns??1)),i=[];if(d.title&&i.push(`<div class="oi-mg-title">${v(d.title)}</div>`),e.length){i.push(`<div class="oi-mg-grid" style="grid-template-columns:repeat(${r},auto)">`);for(let t of e){let e=_(t),n=t.text?.trim()||m[t.action]?.(t)||t.action,r=e.img?`<img class="oi-mg-img" src="${v(e.img)}" alt="" />`:`<span class="oi-mg-badge">${t.minCoins>0?t.minCoins:`🎁`}</span>`,a=d.showCoins!==!1&&e.coins?`<span class="oi-mg-coins">${e.coins}</span>`:``;i.push(`<div class="oi-mg-row">${r}<span class="oi-mg-name">${v(e.name)}</span>${a}<span class="oi-mg-text">— ${v(n)}</span></div>`)}i.push(`</div>`)}if(t.length){e.length&&i.push(`<div class="oi-mg-sep"></div>`),i.push(`<div class="oi-mg-grid" style="grid-template-columns:repeat(${r},auto)">`);for(let e of t){let t=e.triggers.map(e=>`<span class="oi-mg-code">${v(e)}</span>`).join(` `);i.push(`<div class="oi-mg-cmd">${t}<span class="oi-mg-text">${v(h[e.action]??e.action)}</span></div>`)}i.push(`</div>`)}u.innerHTML=i.join(``)}function b(e){d={...d,...e},r(l,g(d.preset),d.vars),l.style.justifyContent=d.align===`center`?`center`:d.align===`right`?`flex-end`:`flex-start`,y()}function x(e){Array.isArray(e.giftActions)&&(f=e.giftActions),Array.isArray(e.chatCommands)&&(p=e.chatCommands),y()}function S(e){if(e)try{return JSON.parse(decodeURIComponent(escape(atob(e))))}catch{return}}s?(b({preset:`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/${s}/settings`),e=>{let t=e.val(),n=t?.global?.musicGifts??t?.tiktok?.musicGifts;n&&b(n)}),i(r(t,`rooms/${s}/musicGifts`),e=>{let t=e.val();t&&x(t)})}).catch(()=>{})):o?(b({preset:a.get(`preset`)??void 0,vars:S(a.get(`vars`)),title:a.get(`title`)??``,showChatCommands:a.get(`cmds`)!==`0`,showCoins:a.get(`coins`)!==`0`,columns:Number(a.get(`cols`)??`1`),align:a.get(`align`)??`left`}),x({giftActions:[{enabled:!0,giftId:`5655`,giftName:`Rose`,minCoins:0,action:`boost`,amount:1,text:``},{enabled:!0,giftId:`5827`,giftName:`Doughnut`,minCoins:0,action:`top`,amount:1,text:``},{enabled:!0,giftId:``,giftName:``,minCoins:500,action:`skip`,amount:1,text:``}],chatCommands:[{enabled:!0,action:`request`,triggers:[`!sr`,`!play`],permission:`everyone`},{enabled:!0,action:`position`,triggers:[`!pos`],permission:`everyone`}]})):(b({preset:`pro`}),i(e=>{if(e.type===`music_config`&&e.data)x(e.data);else if(e.type===`settings`){let t=e.musicGifts;t&&typeof t==`object`&&b(t)}}),fetch(`/api/music/config`).then(e=>e.json()).then(e=>{e&&x(e)}).catch(()=>{}),fetch(`/api/overlay/settings?platform=`+(a.get(`platform`)??`tiktok`)).then(e=>e.json()).then(e=>{e?.musicGifts&&b(e.musicGifts)}).catch(()=>{}));