1import{h as $,v as z,a as s,cG as G,d1 as U,d4 as O,d5 as J,cJ as K,cK as W,d6 as H,cI as Q,N as X,l as Y,j as e,I as Z,q as b}from"./index-CIhbGVJX.js";const F=[{icon:"ð«",text:"Remove anúncios do app"},{icon:"ð",text:"Filtros avançados de troca"},{icon:"â",text:"Aparece no topo na lista de usuários disponÃveis para troca"},{icon:"ð",text:"Comparar estatÃsticas de outros jogadores"},{icon:"ð¯",text:"Sugestões inteligentes de troca"},{icon:"ð",text:"BenefÃcios nos rankings de premiações"},{icon:"ð¬",text:"Suporte prioritário"}];function ae({onClose:o}){const{user:n}=$(),{coins:m,isPremium:T,isPremiumPro:q,premiumTier:g,refreshPremiumTier:i,showToast:t,syncCoinsFromServer:f}=z(),[x,R]=s.useState([]),[l,y]=s.useState("semiannual"),[u,v]=s.useState(!0),[p,j]=s.useState(!1),[h,N]=s.useState(!1),[w,P]=s.useState(!1),c=G();s.useEffect(()=>{k()},[]);const k=async()=>{v(!0);try{await U(n?.uid??void 0);const a=await O();R(a),a.length>0&&!a.find(r=>r.id===l)&&y(a[0]?.id??"monthly")}catch(a){console.error("Error loading plans:",a)}finally{v(!1)}},_=s.useCallback(async()=>{if(!n?.uid){t("Faça login para assinar o Premium");return}j(!0);try{const a=await J(l);a.success?c&&(await i(),t("Premium Pro ativado com sucesso!"),o()):a.error&&a.error!=="Purchase cancelled"&&t(`Erro: ${a.error}`)}catch(a){console.error("Checkout error:",a);const r=a instanceof Error&&a.message?` (${a.message})`:"";t(`Erro ao iniciar pagamento. Tente novamente.${r}`)}finally{j(!1)}},[l,n,t,c,o,i]),B=s.useCallback(async()=>{P(!0);try{const a=await K();a.success?(await W(),await i(),t("Compras restauradas com sucesso!"),o()):t(a.error||"Nenhuma compra encontrada para restaurar")}catch{t("Erro ao restaurar compras")}finally{P(!1)}},[t,o,i]),L=s.useCallback(async()=>{if(!n?.uid){t("Faça login para usar suas moedas");return}N(!0);try{const a=await H(n.uid,3,1e3);if(a.success){t("Premium Pro ativado por 3 dias!"),await Promise.all([i(),f(!0)]),o();return}a.reason==="insufficient_coins"?t("Você precisa de 1000 moedas para ativar 3 dias de Pro"):a.reason==="already_permanent_pro"?t("Seu Premium Pro já está ativo sem data de expiração"):t(a.error||"Não foi possÃvel ativar o Premium com moedas")}catch(a){console.error("Coin premium purchase error:",a),t("Erro ao ativar Premium com moedas. Tente novamente.")}finally{N(!1)}},[o,i,t,f,n?.uid]),M=s.useCallback(async()=>{try{await Q()}catch{t("Erro ao abrir portal. Tente novamente.")}},[t]),V=T,S=X();return Y.createPortal(e.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm sm:items-center",onClick:o,style:{paddingTop:"env(safe-area-inset-top, 0px)",paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:e.jsxs("div",{className:"animate-scale max-h-[90vh] w-full max-w-lg overflow-y-auto rounded-2xl bg-linear-to-b from-gray-900 to-gray-950 shadow-2xl",style:{paddingBottom:"var(--app-bottom-inset, 0px)"},onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"relative overflow-hidden bg-linear-to-r from-amber-500 via-yellow-400 to-amber-500 px-6 py-6 text-center",children:[e.jsx("div",{className:"absolute -top-8 -left-8 h-32 w-32 rounded-full bg-white/10"}),e.jsx("div",{className:"absolute -right-6 -bottom-6 h-24 w-24 rounded-full bg-white/10"}),e.jsx("button",{onClick:o,className:"absolute top-3 right-3 flex h-8 w-8 items-center justify-center rounded-full bg-black/20 text-lg text-white/80 transition hover:bg-black/30",children:"Ã"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"text-4xl",children:"ð"}),e.jsx("h2",{className:"mt-2 text-2xl font-black text-white drop-shadow",children:"Premium"}),e.jsx("p",{className:"mt-1 text-sm font-medium text-white/90",children:"Desbloqueie todo o potencial do Troca Figurinhas"})]})]}),u?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-amber-400 border-t-transparent"})}):!Z&&(q||V&&g!=="standard")?e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-4 rounded-xl border border-green-500/30 bg-green-500/10 p-4 text-center",children:[e.jsx("span",{className:"text-3xl",children:"â
"}),e.jsx("h3",{className:"mt-2 text-lg font-bold text-green-400",children:"Premium Pro Ativo!"})]}),e.jsx("div",{className:"space-y-2",children:F.map((a,r)=>
1e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-gray-800/50 px-3 py-2",children:[e.jsx("span",{className:"text-lg",children:a.icon}),e.jsx("span",{className:"text-sm text-gray-300",children:a.text}),e.jsx("span",{className:"ml-auto text-green-400",children:"â"})]},r))}),e.jsx("button",{onClick:M,className:"mt-4 w-full rounded-xl border border-gray-600 py-3 text-sm font-bold text-gray-400 transition hover:bg-gray-800",children:"Gerenciar Assinatura"})]}):e.jsxs("div",{className:"p-6",children:[g==="standard"&&e.jsxs("div",{className:"mb-4 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-center",children:[e.jsx("span",{className:"text-2xl",children:"â¬ï¸"}),e.jsx("h3",{className:"mt-1 text-base font-bold text-amber-400",children:"Upgrade para Pro â 50% OFF"}),e.jsx("p",{className:"mt-1 text-xs text-amber-300/80",children:"Você tem o Premium Standard. Assine o Pro com 50% de desconto e desbloqueie todas as funções!"})]}),e.jsx("div",{className:"mb-6 space-y-2",children:F.map((a,r)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-gray-800/50 px-3 py-2",children:[e.jsx("span",{className:"text-lg",children:a.icon}),e.jsx("span",{className:"text-sm text-gray-300",children:a.text})]},r))}),e.jsxs("div",{className:"mb-4 rounded-xl border border-yellow-500/30 bg-yellow-500/10 p-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-2xl",children:"ðª"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"text-sm font-black text-yellow-300",children:"Premium Pro por moedas"}),e.jsxs("p",{className:"mt-1 text-xs text-yellow-100/80",children:["Use 1000 moedas para ativar 3 dias de Premium Pro. Seu saldo atual: ",m.toLocaleString("pt-BR"),"."]})]})]}),e.jsx("button",{onClick:()=>void L(),disabled:h||m<1e3,className:b("mt-3 w-full rounded-xl py-3 text-sm font-black transition",h||m<1e3?"cursor-not-allowed bg-gray-700 text-gray-400":"bg-yellow-400 text-gray-950 shadow-lg shadow-yellow-400/20 hover:bg-yellow-300 active:scale-[0.98]"),children:h?"Ativando...":"Ativar 3 dias por 1000 moedas"})]}),x.length===0?e.jsxs("div",{className:"mb-4 rounded-xl border border-gray-700 bg-gray-800/50 p-6 text-center",children:[e.jsx("p",{className:"text-sm font-bold text-gray-300",children:"Nenhum plano disponÃvel no momento"}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"Verifique sua conexão e tente novamente."}),e.jsx("button",{onClick:()=>void k(),disabled:u,className:"mt-4 rounded-lg bg-indigo-600 px-4 py-2 text-xs font-bold text-white transition hover:bg-indigo-500 disabled:opacity-50",children:u?"Carregando...":"Tentar novamente"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-4 grid grid-cols-2 gap-3",children:x.map(a=>{const r=l===a.id,C=x.find(I=>I.interval==="month"),d=a.interval==="semiannual",A=d?a.price/6:a.price,E=C&&d?Math.round((1-A/C.price)*100):0,D=d?"Melhor custo-benefÃcio · economize pagando semestral":"Flexibilidade total · cancele quando quiser";return e.jsxs("button",{onClick:()=>y(a.id),className:b("relative rounded-xl border-2 p-4 text-left transition-all",r?"border-amber-400 bg-amber-400/10 shadow-lg shadow-amber-400/20":"border-gray-700 bg-gray-800/50 hover:border-gray-600"),children:[E>0&&e.jsxs("span",{className:"absolute -top-2 -right-1 rounded-full bg-green-500 px-2 py-0.5 text-[10px] font-bold text-white",children:["-",E,"%"]}),e.jsx("p",{className:"text-xs font-bold tracking-wider text-gray-400 uppercase",children:a.title}),e.jsx("p",{className:"mt-1 text-xl font-black text-white",children:a.priceString}),e.jsx("p",{className:"text-[11px] text-gray-500",children:d?`${new Intl.NumberFormat("pt-BR",{style:"currency",currency:a.currencyCode}).format(A)}/mês`:"por mês"}),e.jsx("p",{className:"mt-2 text-[10px] leading-snug text-amber-100/80",children:D}),r&&e.jsx("div",{className:"absolute top-2 right-2 flex h-5 w-5 items-center justify-center rounded-full bg-amber-400",children:e.jsx("span",{className:"text-xs text-black",children:"â"})})]},a.id)})}),e.jsx("button",{onClick:_,disabled:p||!l,className:b("w-full rounded-xl py-4 text-base font-black text-white shadow-lg transition-all",p?"cursor-not-allowed bg-gray-600":"bg-linear-to-r from-amber-500 to-yellow-400 shadow-amber-400/30 hover:shadow-amber-400/50 active:scale-[0.98]"),children:p?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),"Redirecionando..."]}):"Assinar Premium Pro"}),!c&&e.jsx("p",{className:"mt-2 text-center text-[11px] text-gray-500",children:"Pagamento seguro via Stripe. Cancele a qualquer momento."}),c&&e.jsx("button",{onClick:B,disabled:w,className:"mt-2 w-full rounded-xl border border-gray-600 py-2 text-sm font-medium text-gray-400 transition hover:bg-gray-800",children:w?"Restaurando...":"Restaurar Compras"}),e.jsxs("div",{className:"mt-4 border-t border-gray-700 pt-3 text-center text-[10px] leading-relaxed text-gray-500",children:[e.jsxs("p",{children:["A assinatura é renovada automaticamente ao f
1inal de cada perÃodo, a menos que seja cancelada pelo menos 24 horas antes do término do perÃodo atual. O pagamento é cobrado através da sua conta"," ",S==="ios"?"App Store (Apple)":S==="android"?"Google Play":"Stripe","."]}),e.jsxs("p",{className:"mt-1",children:[e.jsx("a",{href:"/terms",target:"_blank",rel:"noopener noreferrer",className:"text-amber-400 underline",children:"Termos de Uso"})," ⢠",e.jsx("a",{href:"/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-amber-400 underline",children:"PolÃtica de Privacidade"})]})]})]})]})]})}),document.body)}export{ae 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.