1import{cQ as Me,h as ke,v as Ee,K as Re,a as r,cR as ye,bd as Ie,j as e,q as W,Z as be,$ as de,cS as Oe,cT as We,cU as ze,u as $e,cV as qe,cW as Le,cX as He,cY as Ge,Y as Ke,E as ve,l as Ze,D as oe,cZ as ie,F as Je,G as Ue,c_ as Ye,I as Qe,c$ as Xe,d0 as et,ah as tt}from"./index-CIhbGVJX.js";import st from"./InterstitialAd-jU6Ln7K6.js";const rt=Me();function at(a){const[t,o]=r.useState(()=>Date.now());if(r.useEffect(()=>{if(!a)return;const A=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(A)},[a]),!a)return{days:0,hours:0,minutes:0,seconds:0,expired:!0,totalSeconds:0};const u=a.getTime()-t;if(u<=0)return{days:0,hours:0,minutes:0,seconds:0,expired:!0,totalSeconds:0};const f=Math.floor(u/1e3),p=Math.floor(f/86400),k=Math.floor(f%86400/3600),E=Math.floor(f%3600/60),v=f%60;return{days:p,hours:k,minutes:E,seconds:v,expired:!1,totalSeconds:f}}function nt(a){if(!a?.redeemDate||!a?.redeemTime)return null;try{const t=`${String(a.redeemDate)}T${String(a.redeemTime)}:00`,o=new Date(t);return Number.isNaN(o.getTime())?null:o}catch{return null}}function ot(a){try{const[t,o,u]=a.split("-").map(Number);return new Date(t,o-1,u).toLocaleDateString("pt-BR",{day:"numeric",month:"long"})}catch{return a}}function it({type:a,drawConfig:t,hasEntry:o,onClose:u,onClaimed:f}){const{user:p}=ke(),{showToast:k,isPremiumPro:E}=Ee(),{getSlot:v}=Re(),A=v("rewards_countdown_banner"),R=v("rewards_countdown_partner"),z=v("rewards_featured"),[C,M]=r.useState(!1),[K,n]=r.useState(!1),[w,ue]=r.useState(null),[$,D]=r.useState(null),[Z,J]=r.useState(!1),[U,Y]=r.useState(t),[Q,je]=r.useState(!1),c=U,q=typeof c?.redemptionEventId=="string"?c.redemptionEventId:null,X=typeof c?.serverNow=="str
1ing"?c.serverNow:null,ee=typeof c?.scheduledAt=="string"?c.scheduledAt:null,I=Math.max(1,Number(c?.claimWindowMinutes??5)),me=Number(c?.claimedCount??0),Ne=String(a==="weekly"?c?.title??"Resgate Semanal":c?.prize??"Resgate Relâmpago"),xe=String(c?.prize??"Figurinhas"),Se=Number(a==="weekly"?c?.packs??0:c?.quantity??0),T=c?.claimedBy||[],L=!!c?.hasClaimed||(p?.uid?T.includes(p.uid):!1),B=E||o||!!c?.hasTicket,V=!!c?.active,j=r.useMemo(()=>{if(!X)return 0;const d=new Date(X).getTime();return Number.isFinite(d)?d-Date.now():0},[X]),y=r.useMemo(()=>{if(!V)return null;if(ee){const d=new Date(ee);if(!Number.isNaN(d.getTime()))return d}return nt(c)},[c,V,ee]),ge=r.useMemo(()=>y?new Date(y.getTime()-j):null,[y,j]),N=at(ge),te=!!y,se=Date.now()+j,re=V&&!!c?.redeemOpen,S=!!(re||te&&y&&se>=y.getTime()),he=r.useMemo(()=>{if(!y)return!1;const d=y.getTime()+I*60*1e3;return Date.now()+j>d},[y,N,I,j]),F=c?.redeemDate?`${ot(String(c.redeemDate))} à s ${String(c.redeemTime||"12:00")}`:"",O=r.useCallback(async()=>{if(p?.uid){J(!0);try{const d=await ye(p.uid);Y(a==="weekly"?d.currentDraw:d.currentFlash)}catch{}finally{J(!1)}}},[p?.uid,a]);r.useEffect(()=>{if(!S)return;const d=a==="weekly"?"draw_update":"flash_update",h=Ie(()=>void O()),b=rt.subscribe(d,()=>void O());return()=>{h(),b()}},[S,O,a]);const ae=async()=>!c?.requireLocation||typeof navigator>"u"||!navigator.geolocation?null:new Promise(d=>{navigator.geolocation.getCurrentPosition(h=>d({lat:h.coords.latitude,lng:h.coords.longitude,accuracyM:Number.isFinite(h.coords.accuracy)?h.coords.accuracy:null}),()=>d(null),{enableHighAccuracy:!0,maximumAge:15e3,timeout:1e4})}),fe=async()=>{const d=p?.uid;if(!(!d||C||K||L)){if(!S){k("Aguarde o horário de abertura!");return}if(!B){k("Você precisa de um ingresso ou ser Premium PRO!");return}M(!0),D(null);try{let h;if(q){const b=await ae();h=await Oe({userId:d,eventId:q,userName:p?.displayName||"Anônimo",clientSubmittedAt:new Date().toISOString(),clientTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,lat:b?.lat??null,lng:b?.lng??null,accuracyM:b?.accuracyM??null})}else a==="weekly"?h=await We(d,p?.displayName||"Anônimo"):h=await ze(d,p?.displayName||"Anônimo");n(!0),ue({position:h.position,prize:h.prize,message:h.message||"Resgate registrado! Entraremos em contato por email."}),f()}catch(h){const b=h.message||"Erro ao registrar resgate";D(b),k(b)}finally{M(!1)}}},_=a==="weekly";return e.jsxs("div",{className:"fixed inset-0 z-9999 flex flex-col bg-gray-50",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b bg-white px-4 py-3 shadow-sm",style:{paddingTop:"calc(0.75rem + env(safe-area-inset-top, 0px))"},children:[e.jsx("button",{onClick:u,className:"flex h-8 w-8 items-center justify-center rounded-full bg-gray-100 text-gray-600 transition hover:bg-gray-200",children:e.jsx("i",{className:"fa-solid fa-arrow-left text-sm"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-base font-bold text-gray-800",children:[_?"ð":"â¡"," Sala de Resgate"]}),e.jsx("p",{className:"text-xs text-gray-500",children:Ne})]})]}),e.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 pb-32",children:[e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-5 text-center shadow-sm",children:[e.jsx("span",{className:"text-4xl",children:_?"ð":"â¡"}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"Prêmio"}),e.jsx("p",{className:"text-xl font-black text-gray-800",children:xe}),e.jsxs("div",{className:"mt-3 flex justify-center gap-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-black text-purple-600",children:Se}),e.jsx("div",{className:"text-[9px] text-gray-400",children:"figurinhas"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-black text-gray-600",children:q?me:T.length}),e.jsx("div",{className:"text-[9px] text-gray-400",children:"registrados"})]})]})]}),e.jsx("div",{className:W("rounded-xl border px-4 py-2.5 text-center text-xs font-medium",E?"border-yellow-300 bg-yellow-50 text-yellow-700":o?"border-green-300 bg-green-50 text-green-700":"border-red-200 bg-red-50 text-red-600"),children:E?"â Premium PRO â Participação automática":o?"â
Ingresso confirmado":"â Sem ingresso"}),V?!te&&!re?e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-5 text-center shadow-sm",children:[e.jsx("div",{className:"mb-3 text-5xl",children:"ðï¸"}),e.jsx("h3",{className:"text-base font-black text-gray-700",children:"Aguardando próximo resgate"}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"O administrador ainda não marcou data e hora. Você pode se preparar garantindo seu ingresso!"})]}):S?he?e.jsx("div",{className:"rounded-2xl border-2 border-gray-300 bg-white p-5 shadow-sm",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mb-3 text-5xl",children:"â°"}),e.jsx("h3",{className:"text-xl font-black text-gray-600",children:"Resgate Encerrado"}),e.jsxs("p",{className:"mt-2 text-sm text-gray-500",children:["A janela oficial de ",I," minutos se encerrou. Aguarde o próximo resgate!"]}),L&&e.jsx("div",{className:"mt-3 rounded-xl bg-green-50 p-3",children:e.jsx("p",{className:"text-xs text-green-700",children:"â
Seu resgate foi registrado antes do encerramento!"})}),e.jsx("div",{className:"mt-3 rounded-xl bg-gray-50 p-3",children:e.jsxs("p",{className:"text-xs text-gray-600",children:["Total de registros: ",e.jsx("b",{children:T.length})]})})]})}):e.jsx("div",{className:"rounded-2xl border-2 border-green-300 bg-white p-5 shadow-sm",children:K||L?e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mb-3 text-5xl",children:"â
"}),e.jsx("h3",{className:"text-xl font-black text-green-600",children:"Resgate Registrado!"}),e.jsx("p",{className:"mt-2 text-sm text-gray-600",children:w?.message||"Seu resgate foi registrado! Entraremos em contato por email após a conferência."}),e.jsxs("div",{className:"mt-3 rounded-xl bg-blue-50 p-3",children:[e.jsxs("p",{className:"text-xs text-blue-700",children:["Prêmio em disputa: ",e.jsx("b",{children:w?.prize??xe})]}),e.jsxs("p",{className:"mt-1 text-xs text-blue-600",children:["Registros auditáveis: ",e.jsx("b",{children:q?me:T.length})]}),e.jsx("p",{className:"mt-1 text-[10px] text-blue-500",children:"A primeira inscrição registrada pelo servidor vence. Entraremos em contato por email."})]})]}):e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-center gap-1.5",children:[e.jsx("span",{className:"h-2.5 w-2.5 animate-pulse rounded-full bg-green-500"}),e.jsxs("span",{className:"text-xs font-medium text-green-600",children:["Resgate aberto por ",I," min"]})]}),$&&e.jsx("div",{className:"mb-3 rounded-xl bg-red-50 p-3 text-sm text-red-600",children:$}),e.jsx("button",{onClick:fe,disabled:!B||C,className:W("w-full rounded-xl py-4 text-base font-bold shadow-md transition-all active:scale-[0.98]",B&&!C?"bg-green-600 text-white hover:bg-green-700":"cursor-not-allowed bg-gray-200 text-gray-400"),children:C?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx("i",{className:"fa-solid fa-spinner fa-spin"}),"Registrando..."]}):"Registrar Agora"}),!B&&e.jsx("p",{className:"mt-3 text-xs text-red-500",children:"Você precisa de um ingresso ou ser Premium PRO para resgatar"})]})}):e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-5 text-center shadow-sm",children:[e.jsx("p",{className:"mb-1 text-sm font-bold text-gray-700",children:"ⳠResgate abre em"}),F&&e.jsx("p",{className:"mb-3 text-xs text-gray-400",children:F}),e.jsxs("div",{className:"flex justify-center gap-3",children:[N.days>0&&e.jsxs("div",{className:"rounded-xl bg-gray-100 px-4 py-2 text-center",children:[e.jsx("div",{className:"text-2xl font-black text-gray-800",children:N.days}),e.jsx("div",{className:"text-[10px] text-gray-400",children:"dias"})]}),e.jsxs("div",{className:"rounded-xl bg-gray-100 px-4 py-2 text-center",children:[e.jsx("div",{className:"text-2xl font-black text-gray-800",children:String(N.hours).padStart(2,"0")}),e.jsx("div",{className:"text-[10px] text-gray-400",children:"horas"})]}),e.jsxs("div",{className:"rounded-xl bg-gray-100 px-4 py-2 text-center",children:[e.jsx("div",{className:"text-2xl font-black text-gray-800",children:String(N.minutes).padStart(2,"0")}),e.jsx("div",{className:"text-[10px] text-gray-400",children:"min"})]}),e.jsxs("div",{className:"rounded-xl bg-gray-100 px-4 py-2 text-center",children:[e.jsx("div",{className:"text-2xl font-black text-gray-800",children:String(N.seconds).padStart(2,"0")}),e.jsx("div",{className:"text-[10px] text-gray-400",children:"seg"})]})]}),e.jsx("p",{className:"mt-3 text-[10px] text-gray-400",children:"O bot
1ão de resgate será liberado automaticamente no horário marcado"})]}):e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white p-5 text-center shadow-sm",children:[e.jsx("div",{className:"mb-3 text-5xl",children:"ð¤"}),e.jsx("h3",{className:"text-base font-black text-gray-700",children:"Sem resgate ativo no momento"}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"O administrador encerrou este resgate. Fique atento â em breve abrirá um novo!"})]}),e.jsx("button",{onClick:O,disabled:Z,className:"w-full rounded-xl border border-gray-200 bg-white py-2.5 text-xs text-gray-500 transition hover:bg-gray-50 active:scale-[0.98]",children:Z?e.jsxs("span",{children:[e.jsx("i",{className:"fa-solid fa-spinner fa-spin mr-1"}),"Atualizando..."]}):e.jsxs("span",{children:[e.jsx("i",{className:"fa-solid fa-arrows-rotate mr-1"}),"Atualizar"]})}),e.jsxs("div",{className:"rounded-2xl border border-blue-200 bg-blue-50 shadow-sm",children:[e.jsxs("button",{onClick:()=>je(d=>!d),className:"flex w-full items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl",children:"ðï¸"}),e.jsx("span",{className:"text-sm font-bold text-gray-800",children:"Como conseguir ingresso?"})]}),e.jsx("i",{className:W("fa-solid text-xs text-gray-400 transition-transform",Q?"fa-chevron-up":"fa-chevron-down")})]}),Q&&e.jsxs("div",{className:"border-t border-blue-200 px-4 pb-4 text-[11px] leading-relaxed text-gray-700",children:[e.jsxs("ul",{className:"mt-3 space-y-2",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-blue-200 text-[10px] font-bold text-blue-800",children:"ðª"}),"Use suas ",e.jsx("b",{children:"moedas"})," na tela principal para comprar um ingresso pelo valor configurado pelo admin."]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-blue-200 text-[10px] font-bold text-blue-800",children:"ðº"}),"Assista vÃdeos dentro do app: cada vÃdeo dá moedas",_?".":" e, no Flash, também pode conceder o ingresso direto."]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-yellow-200 text-[10px] font-bold text-yellow-800",children:"â"}),"Seja ",e.jsx("b",{children:"Premium PRO"})," e participe automaticamente de todos os resgates, sem precisar comprar ingresso."]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-green-200 text-[10px] font-bold text-green-800",children:"ð¥"}),"Indique amigos no dia quando essa regra estiver ativa para liberar ingresso sem moedas."]})]}),e.jsx("p",{className:"mt-3 text-[10px] text-gray-500",children:"â¹ï¸ O botão só fica ativo quando o resgate abre. Entre aqui na hora marcada e clique em âRegistrar Agoraâ."})]})]}),e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 p-3",children:[e.jsx("p",{className:"mb-1.5 text-xs font-bold text-amber-700",children:"âï¸ Regra de apuração"}),e.jsxs("div",{className:"space-y-0.5 text-[11px] text-amber-600",children:[e.jsx("p",{children:"ð¥ A primeira inscrição confirmada pelo servidor vence."}),e.jsx("p",{children:"ð§¾ Os 10 primeiros registros ficam no relatório de auditoria."}),e.jsx("p",{children:"â±ï¸ O relógio oficial é o do servidor, não o do aparelho."}),e.jsx("p",{children:"âï¸ Entraremos em contato por email após a conferência."})]})]}),e.jsx(be,{slot:A}),R&&R.enabled&&e.jsx(de,{slot:R}),z&&z.enabled&&e.jsx(de,{slot:z})]}),e.jsx("div",{className:"fixed right-0 bottom-0 left-0 border-t border-gray-100 bg-white p-2",style:{paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:e.jsx(be,{slot:v("appshell_bottom"),className:"mx-auto max-w-md"})})]})}const g={entryCost:50,energyPerVideo:1,energyPerSticker:125,videoRewardCoins:10,maxExtraVideosPerDay:10,consecutiveAllowed:2,cooldownBetweenBursts:3e5},le=()=>Qe&&ve();function ce(a,t){const o=Number.parseInt(a??"",10);return Number.isFinite(o)&&o>0?o:t}function lt(a){try{const[t,o,u]=a.split("-").map(Number);return new Date(t,o-1,u).toLocaleDateString("pt-BR",{day:"numeric",month:"long"})}catch{return a}}function ct(a){if(!a?.redeemDate||!a?.redeemTime)return null;try{const t=`${String(a.redeemDate)}T${String(a.redeemTime)}:00`,o=new Date(t);return Number.isNaN(o.getTime())?null:o}catch{return null}}
1function dt(a){const[t,o]=r.useState(()=>Date.now());if(r.useEffect(()=>{if(!a)return;const A=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(A)},[a]),!a)return{days:0,hours:0,minutes:0,seconds:0,expired:!0,totalSeconds:0};const u=a.getTime()-t;if(u<=0)return{days:0,hours:0,minutes:0,seconds:0,expired:!0,totalSeconds:0};const f=Math.floor(u/1e3),p=Math.floor(f/86400),k=Math.floor(f%86400/3600),E=Math.floor(f%3600/60),v=f%60;return{days:p,hours:k,minutes:E,seconds:v,expired:!1,totalSeconds:f}}function xt({onNavigate:a}){const{t}=$e(),{user:o}=ke(),{showToast:u,coins:f,triggerSupabaseSync:p,isPremiumPro:k,syncCoinsFromServer:E,setCoinsFromServer:v,showCoinAnimation:A}=Ee(),{getSlot:R}=Re(),z=R("rewards_partner"),C=R("rewards_featured"),M=R("rewards_extra"),K=R("rewards_video_footer"),[n,w]=r.useState(()=>{const s=localStorage.getItem("trocafigurinhas_rewards_v2")??localStorage.getItem(qe("v2")),l={potEnergy:0,potStickers:0,currentDraw:null,currentFlash:null,extraVideosToday:0,consecutiveCount:0,lastBurstEnd:0,lastDay:null,hasWeeklyEntry:!1,hasFlashEntry:!1,weeklyWinner:null,flashWinner:null};if(s)try{const x=JSON.parse(s),m=new Date().toDateString();return x.lastDay!==m&&(x.extraVideosToday=0,x.consecutiveCount=0,x.lastBurstEnd=0,x.lastDay=m),x.consecutiveCount>=g.consecutiveAllowed&&x.lastBurstEnd>0&&Date.now()-x.lastBurstEnd>=g.cooldownBetweenBursts&&(x.consecutiveCount=0),{...l,...x}}catch{return l}return l}),[ue,$]=r.useState(!1),[D,Z]=r.useState(null),[J,U]=r.useState(!1),[Y,Q]=r.useState(null),[je,c]=r.useState({progress:0,required:2,awardedToday:!1}),[q,X]=r.useState(!1),[ee,I]=r.useState([]),[me,Ne]=r.useState(!1),[xe,Se]=r.useState(!1),[T,L]=r.useState(!1),B=r.useRef(null),[V,j]=r.useState(!1),[y,ge]=r.useState(!1),[N,te]=r.useState(g.entryCost),[se,re]=r.useState(g.energyPerVideo),[S,he]=r.useState(g.videoRewardCoins),[F,O]=r.useState(g.maxExtraVideosPerDay),[ae,fe]=r.useState(g.energyPerSticker);r.useEffect(()=>{(async()=>{try{const[s,l,x,m]=await Promise.all([oe(ie("entry_cost")),oe(ie("community_pot_video")),oe(ie("video_reward_coins")),oe(ie("max_extra_videos_per_day"))]);te(ce(s,g.entryCost)),re(ce(l,g.energyPerVideo)),he(ce(x,g.videoRewardCoins)),O(ce(m,g.maxExtraVideosPerDay))}catch(s){console.error("[Rewards] Erro ao carregar config de economia:",s)}})()},[]),r.useEffect(()=>{const i={...n,lastDay:new Date().toDateString()};localStorage.setItem("trocafigurinhas_rewards_v2",JSON.stringify(i)),p()},[n,p]),r.useEffect(()=>{T&&y&&(requestAnimationFrame(()=>{B.current?.scrollIntoView({behavior:"smooth",block:"start"})}),ge(!1))},[T,y]),r.useEffect(()=>{const i=o?.uid;i&&(ye(i).then(s=>{w(l=>({...l,potEnergy:s.potEnergy,potStickers:s.potStickers??s.potPackets??0,currentDraw:s.currentDraw,currentFlash:s.currentFlash,hasWeeklyEntry:s.hasWeeklyEntry,hasFlashEntry:s.hasFlashEntry,weeklyWinner:s.weeklyWinner,flashWinner:s.flashWinner})),s.energyPerSticker!=null&&s.energyPerSticker>0&&fe(s.energyPerSticker)}).catch(s=>{console.error("[Rewards] Erro ao carregar:",s)}),Le(10).then(I).catch(s=>console.error("[Rewards] Erro ao carregar histórico:",s)))},[o]),r.useEffect(()=>{if(!n.currentFlash?.active)return;const i=o?.uid;if(!i)return;const s=He(l=>{w(x=>({...x,currentFlash:l,hasFlashEntry:l.ticketHolders?.includes(i)??!1})),l.redeemOpen&&!n.currentFlash?.redeemOpen&&u(t("rewards.redeemOpen"))});return()=>s()},[n.currentFlash?.active]),r.useEffect(()=>{if(!n.currentDraw?.active)return;const i=Ge(s=>{w(l=>({...l,currentDraw:s})),s.redeemOpen&&!n.currentDraw?.redeemOpen&&u(t("rewards.redeemOpen"))});return()=>i()},[n.currentDraw?.active]);const _=r.useCallback(()=>{if(le())return{can:!0,message:"",cooldownSeconds:0};const i=Date.now();if(n.extraVideosToday>=F)return{can:!1,message:t("rewards.dailyLimitReached"),cooldownSeconds:0};if(n.consecutiveCount>=g.consecutiveAllowed){const s=i-n.lastBurstEnd;if(s<g.cooldownBetweenBursts){const l=g.cooldownBetweenBursts-s,x=Math.ceil(l/6e4);return{can:!1,message:t("rewards.waitMinutes",{min:x}),cooldownSeconds:Math.ceil(l/1e3)}}}return{can:!0,message:"",cooldownSeconds:0}},[F,n.extraVideosToday,n.consecutiveCount,n.lastBurstEnd,t]),d=async()=>{const i=_();if(!i.can){u(i.message);return}if(ve()){const s=await Je();s.rewarded?(Ue(),await h()):s.notReady?u(t("rewards.adNotReady",{defaultValue:"Anúncio ainda carregando. Aguarde alguns segundos e tente novamente."}
1)):u(t("rewards.videoNotCompleted",{defaultValue:"Assista o vÃdeo completo para ganhar a recompensa"}));return}$(!0)},h=async()=>{$(!1);const l=(n.consecutiveCount>=g.consecutiveAllowed&&Date.now()-n.lastBurstEnd>=g.cooldownBetweenBursts?0:n.consecutiveCount)+1,x=o?.uid;if(x)try{const m=await Ye({userId:x,energyPerVideo:se,energyPerPacket:ae});if(m.rate_limited){v(m.coins),w(G=>({...G,potEnergy:m.pot_energy,potStickers:m.pot_packets||m.pot_stickers||0,extraVideosToday:F})),u(t("rewards.rateLimited",{defaultValue:"Limite diário de vÃdeos atingido. Volte amanhã!"}));return}w(G=>({...G,potEnergy:m.pot_energy,potStickers:m.pot_packets||m.pot_stickers||0,extraVideosToday:le()?0:G.extraVideosToday+1,consecutiveCount:le()?0:l,lastBurstEnd:!le()&&l>=g.consecutiveAllowed?Date.now():G.lastBurstEnd})),j(!0),setTimeout(()=>j(!1),2e3),v(m.coins),A(S);const _e=l>=g.consecutiveAllowed?" "+t("rewards.nextVideosIn"):"";u(t("rewards.videoReward",{coins:S})+_e)}catch(m){console.error("[Rewards] Erro ao aplicar recompensa de vÃdeo:",m),u("Erro ao registrar vÃdeo. Tente novamente.")}else w(m=>({...m,extraVideosToday:m.extraVideosToday+1,consecutiveCount:l,lastBurstEnd:l>=g.consecutiveAllowed?Date.now():m.lastBurstEnd})),j(!0),setTimeout(()=>j(!1),2e3)};r.useEffect(()=>{let i=!1;return(async()=>{try{const l=await Xe();i||Q(l)}catch{}if(o?.uid)try{const l=await et(o.uid);i||c(l)}catch{}})(),()=>{i=!0}},[o?.uid,n.currentFlash]);const b=F-n.extraVideosToday,pe=_(),[Ce,De]=r.useState(0);r.useEffect(()=>{if(pe.cooldownSeconds<=0)return;const i=setInterval(()=>De(s=>s+1),1e3);return()=>clearInterval(i)},[pe.cooldownSeconds>0]);const we=Ce>=0?_():pe,Te=Math.floor(we.cooldownSeconds/60),Ve=we.cooldownSeconds%60,ne=ae,Pe=ne>0?n.potEnergy%ne:0,Ae=ne>0?Pe/ne*100:0,H=n.currentFlash;H?.active,H?.redeemOpen,H?.quantity,Number(Y?.coinsRule?.cost??H?.ticketCost??N);const P=n.currentDraw;P?.active,Number(P?.ticketCost??N);const Be=P?.claimedBy||[];o?.uid&&Be.includes(o.uid),String(H?.prize??"Figurinhas"),String(n.weeklyWinner?.winnerName??""),String(n.weeklyWinner?.prize??"--"),String(n.flashWinner?.winnerName??""),String(n.flashWinner?.prize??"--");const Fe=r.useMemo(()=>ct(P),[P]);return dt(Fe),P?.redeemDate&&`${lt(String(P.redeemDate))}${t("common.at")}${String(P.redeemTime||"20:00")}`,e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"bg-linear-to-r from-purple-600 to-indigo-600 px-4 py-3 text-white",children:[e.jsxs("h2",{className:"text-lg font-black",children:["ð ",t("rewards.title")]}),e.jsx("p",{className:"text-xs opacity-90",children:t("rewards.subtitle")})]}),e.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 pb-20",children:[e.jsx("div",{className:"w-full",children:e.jsx(Ke,{slotId:"rewards_affiliate",fallbackSlot:z,compact:!0,position:"rewards",className:"flex w-full items-center justify-center"})}),e.jsxs("div",{onClick:()=>L(i=>!i),className:"relative cursor-pointer overflow-hidden rounded-2xl bg-linear-to-br from-purple-600 via-indigo-600 to-blue-600 p-5 shadow-lg transition active:scale-[0.98]",children:[e.jsx("div",{className:"absolute inset-0 -skew-x-12 bg-linear-to-r from-transparent via-white/5 to-transparent"}),e.jsxs("div",{className:"relative z-10",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-black text-white",children:["ð ",t("rewards.communityPotTitle",{defaultValue:"Pote da comunidade"})]}),e.jsx("p",{className:"text-sm text-white/80",children:t("rewards.communityPotDesc",{defaultValue:"A comunidade contribui para aumentar o prêmio da semana! Assista vÃdeos e ajude!"})})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-4xl font-black text-yellow-300 drop-shadow-lg",children:n.potStickers}),e.jsx("div",{className:"text-xs text-white/80",children:t("rewards.stickersWon")})]})]}),e.jsxs("div",{className:"rounded-xl bg-black/30 p-4",children:[e.jsx("div",{className:"mb-2 text-sm text-white",children:t("rewards.progressToSticker")}),e.jsxs("div",{className:"relative h-5 overflow-hidden rounded-full bg-gray-800",children:[e.jsx("div",{className:W("h-full rounded-full bg-linear-to-r from-yellow-400 via-yellow-300 to-yellow-500 transition-all duration-1000 ease-out",V&&"shadow-[0_0_16px_rgba(250,204,21,0.8)]"),style:{width:`${Math.max(Ae,3)}%`}}),V&&e.jsx("div",{className:"absolute inset-0 animate-pulse rounded-full bg-yellow-300/30"})]}),V?e.jsxs("p",{className:"mt-2 animate-bounce text-center text-xs font-bold text-yellow-300",children:["+",se," â¡ ",t("rewards.potAnimationMsg")]}):e.jsxs("p",{className:"mt-2 text-center text-xs text-white/60",children:["ð ",t("rewards.tapToExpandVideos",{defaultValue:"Toque para abrir a seção de vÃdeos"})]})]})]})]}),e.jsx("div",{ref:B,className:W(!T&&"hidden"),children:e.jsx(be,{slot:K,className:"mt-4"})}),!1,e.jsxs("div",{className:"rounded-2xl border-2 border-green-300 bg-linear-to-br from-green-50 to-emerald-50 p-5 shadow-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-gray-800",children:t("rewards.watchVideosTitle")}),e.jsx("p",{className:"text-xs text-gray-500",children:t("rewards.videoHelpsStickers")})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:W("text-2xl font-black",b>0?"text-green-600":"text-gray-400"),children:b}),e.jsx("div",{className:"text-xs text-gray-500",children:t("rewards.remainingToday")})]})]}),e.jsx("div",{className:"mb-3 rounded-xl bg-white/70 p-3",children:e.jsx("p",{className:"text-[11px] text-gray-600",children:t("rewards.watchVideosInfo")})}),we.can?e.jsx("button",{onClick:d,className:"w-full rounded-xl bg-linear-to-r from-green-500 to-emerald-500 py-4 text-lg font-bold text-white shadow-md transition-all hover:shadow-lg active:scale-95",children:t("rewards.watchButtonCta",{coins:S})}):b<=0?e.jsxs("div",{className:"rounded-xl bg-gray-100 py-4 text-center",children:[e.jsx("p",{className:"text-sm font-bold text-gray-500",children:t("rewards.dailyLimitReached")}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:t("rewards.dailyLimitMsg")})]}):e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 py-4 text-center",children:[e.jsxs("p",{className:"text-xs font-medium text-amber-600",children:[e.jsx("i",{className:"fa-regular fa-clock mr-1"}),t("rewards.nextVideoIn")]}),e.jsxs("p",{className:"mt-1 font-mono text-2xl font-black text-amber-700",children:[String(Te).padStart(2,"0"),":",String(Ve).padStart(2,"0")]})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-center gap-4",children:[e.jsx("span",{className:"text-xs text-gray-400",children:t("rewards.coinsPerVideo",{coins:S})}),e.jsx("span",{className:"text-xs text-gray-400",children:t("rewards.contributeToPot")})]})]}),!1,C&&C.enabled&&e.jsx(de,{slot:C}),M&&M.enabled&&e.jsx(de,{slot:M}),!1]}),ue&&!ve()&&e.jsx(st,{onClose:h}),D&&e.jsx(it,{type:D,drawConfig:D==="weekly"?n.currentDraw:n.currentFlash,hasEntry:D==="weekly"?n.hasWeeklyEntry:n.hasFlashEntry,onClose:()=>{tt(),Z(null)},onClaimed:()=>{w(D==="weekly"?s=>({...s,hasWeeklyEntry:!1}):s=>({...s,hasFlashEntry:!1}));const i=o?.uid;i&&ye(i).then(s=>{w(l=>
1({...l,currentDraw:s.currentDraw,currentFlash:s.currentFlash,hasWeeklyEntry:s.hasWeeklyEntry,hasFlashEntry:s.hasFlashEntry}))})}}),J&&Ze.createPortal(e.jsx("div",{className:"fixed inset-0 z-9998 flex items-center justify-center bg-black/60 p-6",style:{paddingTop:"env(safe-area-inset-top, 0px)",paddingBottom:"env(safe-area-inset-bottom, 0px)"},onClick:()=>U(!1),children:e.jsxs("div",{className:"w-full max-w-sm rounded-2xl bg-white p-6 shadow-2xl",onClick:i=>i.stopPropagation(),children:[e.jsx("div",{className:"mb-4 text-center text-5xl",children:"ðï¸"}),e.jsx("h3",{className:"mb-2 text-center text-lg font-black text-gray-800",children:t("rewards.noTicketTitle",{defaultValue:"Você precisa de um ingresso!"})}),e.jsx("p",{className:"mb-4 text-center text-sm text-gray-600",children:t("rewards.noTicketDesc",{defaultValue:"Para entrar na Sala de Resgate, compre um ingresso com moedas ou seja assinante Premium PRO."})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-center text-xs text-gray-500",children:t("rewards.howToGetEntry")}),e.jsxs("div",{className:"rounded-xl bg-gray-50 p-3 text-xs text-gray-600",children:[e.jsxs("p",{children:["ðª ",e.jsx("b",{children:"Moedas"})," â ",t("rewards.getEntryWithCoins")]}),e.jsxs("p",{className:"mt-1",children:["â ",e.jsx("b",{children:"Premium PRO"})," â ",t("rewards.getEntryWithPremium")]})]})]}),e.jsx("button",{onClick:()=>U(!1),className:"mt-4 w-full rounded-xl bg-purple-600 py-3 text-sm font-bold text-white transition hover:bg-purple-700 active:scale-95",children:t("rewards.understood")})]})}),document.body)]})}
1export{xt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.