PageSourceSearch

https://assets.recargajogo.com.br/gop/mshop/www/live/assets/ViewLoyaltyRedeem-c72b9101.js

js recargajogo.com.br collected 2026-10-04 18:33:34 UTC 18,253 bytes, 1 lines download raw bytes

1import{q as Z,H as V,I as xe,c as he,a1 as be,E as ge,j as e,R as fe,ac as we,o,p as C,z as ee,Q as _e}from"./index-878ce38c.js";import{r as u}from"./react-0e2a0c96.js";import{N as ye,C as te}from"./NotEnoughTicketsPopup-2e47d3a6.js";import{aV as Q,ah as O,bb as Ne,bc as ve,bd as Ce,be as Ee,bf as Re,bg as ke}from"./images-0c2231a1.js";import{c as v,g as Ae}from"./constants-004cc5a2.js";import{u as Se}from"./useLoyaltyRedeemInfo-e240e70a.js";import{g as Pe}from"./error-d088b380.js";const Be=()=>{const{region:a}=Z(),[t,n]=u.useState(!1),p=u.useRef(!1);return{redeem:u.useCallback(async({activityId:x,itemPk:m,quantity:h,packedRoleId:g})=>{if(p.current)return!1;p.current=!0,n(!0);try{await V.post("/preflight");const s=await V.post("/loyalty/redeem",{activity_id:x,item_pk:m,quantity:h,region:a,packed_role_id:g},{headers:{"x-csrf-token":xe("__csrf__")}});if(s.data.code!==0)throw new Error(s.data.error||"error_server");return!0}finally{p.current=!1,n(!1)}},[a]),isRedeeming:t}},Le={[v.NONE]:"linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 100%)",[v.GREY]:"linear-gradient(180deg, rgba(131,133,147,0) 0%, rgba(131,133,147,0.2) 89%)",[v.GREEN]:"linear-gradient(180deg, rgba(60,210,157,0) 0%, rgba(60,210,157,0.2) 89%)",[v.BLUE]:"linear-gradient(180deg, rgba(29,191,230,0) 0%, rgba(29,191,230,0.2) 100%)",[v.PURPLE]:"linear-gradient(180deg, rgba(184,56,255,0) 0%, rgba(184,56,255,0.2) 100%)",[v.ORANGE]:"linear-gradient(180deg, rgba(255,187,0,0) 0%, rgba(255,187,0,0.2) 89%)",[v.RED]:"linear-gradient(180deg, rgba(255,77,79,0) 0%, rgba(255,77,79,0.2) 89%)"},$=a=>{const t=Math.min(v.RED,Math.max(v.NONE,a)),n=Ae(t);return{overlay:Le[t],palette:n}},Me=(a,t)=>{const n=Math.max(0,a.limit-a.redeemed);return n<=0?0:t===void 0||!Number.isFinite(t)||a.cost<=0?n:Math.min(n,Math.floor(t/a.cost))},Fe=a=>String(Math.trunc(Math.abs(a))).length>=7,K="inline-flex h-4 items-center bg-[#414149] px-1 text-[10px]/none font-medium tracking-tight text-white/80",Ie={diamondPx:28,trackHeightPx:2,trackMarginX:2},Te=({value:a,max:t,disabled:n,onChange:p})=>{const l=Math.min(Math.max(1,a),t),x=t<=1?100:(l-1)/(t-1)*100,{diamondPx:m,trackHeightPx:h,trackMarginX:g}=Ie,s=m/2,b=u.useRef(null),c=u.useRef(!1),E=u.useCallback(i=>{const I=b.current;if(!I||t<=1||n)return;const P=I.getBoundingClientRect(),R=P.width-m;if(R<=0)return;const k=i-P.left-s,z=Math.max(0,Math.min(1,k/R)),f=Math.round(1+z*(t-1));p(f)},[t,n,p,m,s]),A=i=>{t<=1||n||(i.preventDefault(),c.current=!0,i.currentTarget.hasPointerCapture(i.pointerId)||i.currentTarget.setPointerCapture(i.pointerId),E(i.clientX))},S=i=>{t<=1||n||!c.current&&!i.currentTarget.hasPointerCapture(i.pointerId)||(i.preventDefault(),E(i.clientX))},L=i=>{c.current=!1,i.currentTarget.hasPointerCapture(i.pointerId)&&i.currentTarget.releasePointerCapture(i.pointerId)};return o("div",{className:"flex w-full items-center gap-2",children:[e("button",{type:"button",className:"flex h-9 w-9 shrink-0 items-center justify-center",disabled:n||l<=1,onClick:()=>p(Math.max(1,l-1)),children:n||l<=1?e(ve,{"aria-hidden":!0,className:"h-7 w-7"}):e(Ce,{"aria-hidden":!0,className:"h-7 w-7"})}),o("div",{ref:b,className:"relative h-9 min-w-0 flex-1 touch-none select-none",style:{marginLeft:g,marginRight:g},onPointerDown:A,onPointerMove:S,onPointerUp:L,onPointerCancel:L,onLostPointerCapture:()=>{c.current=!1},role:"slider","aria-valuemin":1,"aria-valuemax":t,"aria-valuenow":l,"aria-disabled":n||t<=1,children:[e("div",{className:"absolute top-1/2 -translate-y-1/2 rounded-full bg-[#3A3D4D]",style:{height:h,left:s,right:s}}),e("div",{className:"absolute top-1/2 -translate-y-1/2 rounded-full bg-[#F4BA2A]",style:{height:h,left:s,width:"calc((100% - ".concat(m,"px) * ").concat(x," / 100)")}}),e("div",{className:"absolute top-1/2 z-[1] -translate-x-1/2 -translate-y-1/2 cursor-grab select-none active:cursor-grabbing",style:{height:m,width:m,left:"calc(".concat(s,"px + (100% - ").concat(m,"px) * ").concat(x," / 100)")},children:e(Ee,{"aria-hidden":!0,className:"h-7 w-7"})})]}),e("button",{type:"button",className:"flex h-9 w-9 shrink-0 items-center justify-center",disabled:n||l>=t,onClick:()=>p(Math.min(t,l+1)),children:n||l>
1=t?e(Re,{"aria-hidden":!0,className:"h-7 w-7"}):e(ke,{"aria-hidden":!0,className:"h-7 w-7"})})]})},W=54/171*100,ze=5/171*100,De="polygon(0 0, ".concat(W+ze,"% 0, ").concat(W,"% 100%, 0 100%)"),q=({palette:a,heightClassName:t,roundedClassName:n})=>o(ee,{children:[e("div",{className:C("pointer-events-none absolute bottom-0 start-0 z-0 w-full",t,n),style:{backgroundColor:a.base}}),e("div",{className:C("pointer-events-none absolute bottom-0 start-0 z-0 w-full",t,n),style:{backgroundColor:a.accent,clipPath:De}})]}),ae={card:"#1C1E2B",modal:"#242434"},ne={sm:{cut:8,tip:5},md:{cut:12,tip:8},lg:{cut:12,tip:8}},T=({variant:a,gapBg:t,className:n,buttonClassName:p,fontSizePx:l,fillColor:x="#FABF00",hoverFillColor:m="#e0a721",children:h,disabled:g,disabledAppearance:s="grey",...b})=>{const c=ne[a],E=ae[t],A=a==="sm"?"inline-flex align-middle":a==="md"?"inline-flex min-w-0 flex-1 align-middle":"block w-full";if(g&&s==="grey")return e("button",{type:"button",disabled:!0,className:C(a==="sm"&&"h-6 cursor-not-allowed bg-[#424965] px-2 text-xs/none font-semibold text-white/50",a==="md"&&"h-10 w-full min-w-0 cursor-not-allowed rounded-md bg-[#424965] text-sm font-bold text-white/50",a==="lg"&&"h-10 w-full cursor-not-allowed bg-[#424965] text-[28px]/none font-bold text-white/50",n),style:{fontSize:l?"".concat(l,"px"):void 0},...b,children:h});const S=a==="sm"?"flex h-6 w-full min-w-0 items-center justify-center border-0 px-2.5 text-xs font-bold text-[#1A1A1A] disabled:cursor-not-allowed":a==="md"?"flex h-10 w-full min-w-0 items-center justify-center border-0 text-sm font-bold text-[#1A1A1A] disabled:cursor-not-allowed":"flex h-10 w-full items-center justify-center border-0 text-[28px] font-bold leading-none text-[#1A1A1A] disabled:cursor-not-allowed";return e(te,{className:C(A,n),buttonClassName:C(S,p),contentClassName:"block",gapColor:E,fillColor:x,hoverFillColor:m,cutPx:c.cut,tipPx:c.tip,fontSizePx:l,disabled:g,disabledContainerClassName:s==="dim"?"opacity-60":void 0,...b,children:h})},je=({variant:a,gapBg:t,className:n,buttonClassName:p,children:l,disabled:x,...m})=>{const h=ne[a],g=ae[t],s=a==="md"?"inline-flex min-w-0 flex-1 align-middle":"block w-full",b=a==="md"?"flex h-10 w-full min-w-0 items-center justify-center border-0 text-sm font-bold text-[#D8D9E2] disabled:cursor-not-allowed disabled:opacity-60":"flex h-10 w-full items-center justify-center border-0 text-sm font-bold text-[#D8D9E2] disabled:cursor-not-allowed disabled:opacity-60";return e(te,{className:C(s,n),buttonClassName:C(b,p),contentClassName:"block",gapColor:g,fillColor:"#4C4E63",hoverFillColor:"#5c5f73",tipColor:"#5c5f73",cutPx:h.cut,tipPx:h.tip,disabled:x,...m,children:l})},J=()=>{const a="pointer-events-none absolute z-0 h-3 w-3 bg-white/[0.1]",t={clipPath:"polygon(0% 100%, 100% 100%, 0% 0%)"};return e(ee,{children:e("div",{className:"".concat(a," bottom-1.5 start-0.5"),style:t})})},H=({isOpen:a,onClose:t,children:n})=>e(_e,{isOpen:a,onClose:t,dialogClassName:"z-[70]",children:e("div",{className:"flex h-full w-full items-center justify-center px-3 py-6",children:e("div",{className:"relative z-[1] w-full",children:n})})}),Xe=({activity:a,loyaltyInfo:t,role:n,mutateLoyaltyInfo:p})=>{var X,Y;const{t:l}=he(),{region:x,lang:m}=Z(),h=String(a.id),g=a.id,[s,b]=u.useState(null),[c,E]=u.useState(null),[A,S]=u.useState(null),[L,i]=u.useState(null),[I,P]=u.useState(!1),[R,k]=u.useState("none"),{redeem:z,isRedeeming:f}=Be(),{rewards:se,isLoading:le,applyRewardPurchase:re,refresh:ie}=Se(h,(X=n==null?void 0:n.packed_role_id)!=null?X:0,!!n),[D,M]=u.useState(1),w=u.useMemo(()=>be(x,m),[x,m]),G=se,oe=t.user?ge(t.user.balance,x):"—",F=(Y=t.user)==null?void 0:Y.balance,ce=r=>{if(!f){if(r.redeemed>=r.limit){k("limit");return}if(typeof F=="number"&&r.cost>F){P(!0);return}i(null),M(1),b(r),k("confirm")}},j=u.useCallback(()=>{b(null),E(null),S(null),i(null),M(1),k("none")},[]),U=u.useCallback(()=>{j(),P(!0)},[j]),de=async()=>{var _;if(!s||f)return;i(null);const r=D;if(r<1){j();return}if(typeof F=="number"&&s.cost*r>F){U();return}try{if(!await z({activityId:g,itemPk:s.itemPk,quantity:r,packedRoleId:(_=n==null?void 0:n.packed_role_id)!=null?_:0}))return;await re(s.itemPk,r),await p(d=>{var B;return(B=d==null?void 0:d.data)!=null&&B.user?{...d,data:{...d.data,user:{...d.data.user,balance:d.data.user.balance-s.cost*r}}}:d},{revalidate:!1}),b(null),E(s),S(r),k("success")}catch(y){const d=y instanceof Error&&y.message?y.message:"error_server";if(d==="error_redeem_limit_exceeded"){await ie(),await p(),b(null),E(null),S(null),i(null),M(1),k("limit");return}if(d==="error_not_enough_tickets"){U();return}i(Pe(d))}},N=()=>{R==="confirm"&&f||(k("none"),i(null),M(1))},me=l("lbl__redeem_amount"),ue=l("lbl__spent");return le?e("div",{className:"relative z-[2] flex flex-1 items-center justify-center px-4 py-6 text-white",children:e(fe,{className:"py-2",icon:e(we,{className:"mb-1"}),description:l("lbl__loading")})}):o("div",{className:"relative z-[2] w-full pb-10 pt-4 md:pt-6",children:[e("div",{className:"mx-auto w-full max-w-[1016px] px-4 text-white md:px-6",children:G.length===0?e("div",{className:"px-4 py-12 text-center text-sm text-white/60",children:l("msg__empty_here")}):e("div",{className:"mx-auto grid w-full max-w-[464px] grid-cols-2 gap-4 md:w-fit md:max-w-none md:grid-cols-[repeat(4,171px)]",children:G.map(r=>{const _=$(r.rarity),y=Fe(r.cost),d=y?"text-[10px]/none font-semibold":"text-sm/none font-semibold",B=y?"w-[60px]":void 0,pe
1=y?"h-5":void 0;return o("article",{className:"mx-auto flex w-full min-w-0 max-w-[224px] flex-col overflow-hidden border border-[#2F3242] bg-[#1C1E2B] shadow-[0_2px_8px_rgba(0,0,0,0.25)] md:mx-0 md:w-[171px] md:max-w-none",children:[o("div",{className:"relative aspect-[171/148] w-full overflow-hidden bg-[#1F2029] md:h-[148px] md:w-[171px] md:flex-none",children:[e("div",{className:"pointer-events-none absolute inset-0 z-0 bg-[radial-gradient(ellipse_75%_68%_at_50%_44%,rgba(255,255,255,0.07)_0%,transparent_72%)]","aria-hidden":!0}),e("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-0 h-16",style:{background:_.overlay}}),e(J,{}),e(q,{palette:_.palette,heightClassName:"h-[3px]"}),e("img",{src:r.imageSrc,alt:"","aria-hidden":!0,className:"absolute inset-0 z-[1] m-auto aspect-square w-[56%] max-w-[200px] object-contain"}),r.itemQuantity>1&&e("div",{className:"absolute bottom-1 end-1 z-[2] text-sm/none font-medium text-white/60",children:"x".concat(r.itemQuantity.toLocaleString(w))}),e("div",{className:C("absolute start-1 top-1 z-[2]",K),children:l("lbl__redeem_limit",{redeemed:r.redeemed.toLocaleString(w),limit:r.limit.toLocaleString(w)})})]}),o("div",{className:"flex flex-1 flex-col p-2.5 md:p-3",children:[e("div",{className:"min-h-8 mb-2 line-clamp-2 break-words text-sm font-medium leading-snug text-white md:min-h-[40px] md:text-[15px]",children:r.title}),o("div",{className:"mt-auto flex items-center justify-between gap-2",children:[o("div",{className:"inline-flex items-center gap-1 text-[#FFC42E]",children:[e(Q,{"aria-hidden":!0,className:"h-4 w-4 shrink-0"}),e("span",{className:d,children:r.cost.toLocaleString(w)})]}),e(T,{type:"button",variant:"sm",gapBg:"card",className:B,buttonClassName:pe,disabled:f,disabledAppearance:"dim",onClick:()=>ce(r),children:l("btn__redeem")})]})]})]},r.itemPk)})})}),e(H,{isOpen:R==="confirm"&&!!s,onClose:N,children:s&&(()=>{const r=Me(s,F),_=Math.min(D,r),y=_*s.cost,d=$(s.rarity);return o("div",{role:"dialog",className:"mx-auto w-[340px] max-w-[92vw] border border-white/[0.12] bg-[linear-gradient(180deg,#1E1F2A_0%,#1A1B24_55%,#23242E_100%)] px-5 pb-6 pt-4 shadow-[0_16px_48px_rgba(0,0,0,0.55)]",onClick:B=>B.stopPropagation(),children:[o("div",{className:"mb-4 flex items-center justify-between",children:[o("div",{id:"redeem-confirm-title",className:"inline-flex max-w-[min(100%,240px)] shrink-0 items-center gap-2 rounded-sm border border-[#ffffff1a] bg-[#1C1E2B] px-1 py-0.5",children:[e(Q,{"aria-hidden":!0,className:"h-4 w-4 shrink-0"}),e("span",{className:"text-[14px]/none font-bold tabular-nums text-[#F4BA2A]",children:oe})]}),e("button",{type:"button",className:"text-2xl leading-none text-[#8E8EA2]",onClick:N,disabled:f,children:e(O,{})})]}),e("div",{className:"mb-4 flex justify-center",children:e("div",{className:"w-[110px] overflow-hidden border border-[#2F3242] bg-[#1C1E2B] shadow-[0_2px_8px_rgba(0,0,0,0.25)]",children:o("div",{className:"relative h-[110px] w-[110px] overflow-hidden bg-[#1F2029]",children:[e("div",{className:"pointer-events-none absolute inset-0 z-0 bg-[radial-gradient(ellipse_75%_68%_at_50%_44%,rgba(255,255,255,0.07)_0%,transparent_72%)]","aria-hidden":!0}),e("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-0 h-16",style:{background:d.overlay}}),e(J,{}),e(q,{palette:d.palette,heightClassName:"h-[3px]"}),e("img",{src:s.imageSrc,alt:"","aria-hidden":!0,className:"absolute inset-0 z-[1] m-auto aspect-square w-[90px] max-w-[200px] object-contain"}),s.itemQuantity>1&&e("div",{className:"absolute bottom-1 end-1 z-[2] text-sm/none font-medium text-white/60",children:"x".concat(s.itemQuantity.toLocaleString(w))}),e("div",{className:C("absolute start-1 top-1 z-[2]",K),children:l("lbl__redeem_limit",{redeemed:s.redeemed.toLocaleString(w),limit:s.limit.toLocaleString(w)})})]})})}),e("div",{className:"mb-4 flex w-full flex-col items-stretch gap-1.5 px-0.5",children:e("h2",{className:"line-clamp-2 min-h-[44px] break-words text-center text-base font-bold leading-snug text-white",children:s.title})}),o("div",{className:"mb-6 flex w-full flex-col gap-3",children:[e(Te,{value:D,max:r,disabled:f,onChange:M}),o("div",{className:"flex items-center justify-between gap-3 px-0.5 text-sm leading-none",children:[o("div",{className:"min-w-0",children:[e("span",{className:"text-white/60",children:me})," ",e("span",{className:"font-bold text-[#FABF00]",children:_.toLocaleStr
1ing(w)})]}),o("div",{className:"flex min-w-0 items-center justify-end gap-1.5",children:[e("span",{className:"shrink-0 text-white/60",children:ue}),o("span",{className:"inline-flex shrink-0 items-center gap-1",children:[e(Q,{"aria-hidden":!0,className:"h-4 w-4 shrink-0"}),e("span",{className:"font-bold text-[#FABF00]",children:y.toLocaleString(w)})]})]})]})]}),L&&e("p",{className:"mb-3 text-center text-sm text-[#FF6A6A]",children:l(L)}),o("div",{className:"mx-auto flex w-full justify-center gap-4",children:[e(je,{type:"button",variant:"md",gapBg:"modal",className:"!w-[138px] !flex-none",buttonClassName:"text-[16px]",onClick:N,disabled:f,children:l("btn__cancel")}),o(T,{type:"button",variant:"md",gapBg:"modal",className:"!w-[138px] !flex-none",fontSizePx:16,disabled:f,disabledAppearance:"dim",onClick:de,children:[l("btn__confirm"),f?" ...":""]})]})]})})()}),e(H,{isOpen:R==="success"&&!!c,onClose:N,children:c&&(()=>{const r=$(c.rarity);return o("div",{role:"dialog",className:"mx-auto w-[min(92vw,340px)] border border-white/10 bg-[linear-gradient(180deg,#1A1A26_50%,#242434_100%)] px-5 pb-6 pt-4 text-center shadow-[0_16px_40px_rgba(0,0,0,0.45)]",onClick:_=>_.stopPropagation(),children:[e("div",{className:"mb-2 flex justify-end",children:e("button",{type:"button",className:"text-2xl leading-none text-[#8E8EA2] transition-colors hover:text-white/80",onClick:N,children:e(O,{})})}),e("div",{className:"mb-6 flex justify-center",children:e("div",{className:"w-[110px] overflow-hidden border border-[#3B3D4A] bg-[#1C1E2B] shadow-[0_8px_18px_rgba(0,0,0,0.32)]",children:o("div",{className:"relative h-[110px] w-[110px] overflow-hidden bg-[#1F2029]",children:[e("div",{className:"pointer-events-none absolute inset-0 z-0 bg-[radial-gradient(ellipse_75%_68%_at_50%_44%,rgba(255,255,255,0.07)_0%,transparent_72%)]","aria-hidden":!0}),e("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-0 h-16",style:{background:r.overlay}}),e(q,{palette:r.palette,heightClassName:"h-[3px]"}),e("div",{className:"pointer-events-none absolute bottom-[8px] start-[4px] z-[2] h-[12px] w-[12px] bg-white/[0.1]",style:{clipPath:"polygon(0% 100%, 100% 100%, 0% 0%)"}}),e("img",{src:Ne,alt:"","aria-hidden":!0,className:"pointer-events-none absolute start-0 top-0 z-[3] h-12 w-12 object-contain"}),e("img",{src:c.imageSrc,alt:"","aria-hidden":!0,className:"absolute inset-0 z-[1] m-auto aspect-square w-[56%] max-w-[200px] object-contain"}),c.itemQuantity>1&&e("div",{className:"absolute bottom-1 end-1 z-[2] text-sm/none font-medium text-white/60",children:"x".concat(c.itemQuantity.toLocaleString(w))})]})})}),o("div",{className:"mb-2 flex min-w-0 items-center justify-center gap-1 text-[16px]/[16px] font-bold text-white",children:[e("p",{className:"min-w-0 break-words text-center",children:c.itemQuantity>1?"".concat(c.itemQuantity," ").concat(c.title):c.title}),e("span",{className:"shrink-0",children:"x".concat((A!=null?A:1).toLocaleString(w))})]}),e("p",{className:"mx-auto mb-6 max-w-[290px] text-[14px]/[22px] text-white/80",children:l("msg__redeem_success_desc")}),e(T,{type:"button",variant:"lg",gapBg:"modal",fillColor:"#FABF00",hoverFillColor:"#FABF00",fontSizePx:18,onClick:N,className:"mx-auto w-[292px] max-w-full",children:l("btn__ok")})]})})()}),e(H,{isOpen:R==="limit",onClose:N,children:R==="limit"&&o("div",{role:"dialog",className:"mx-auto w-[min(92vw,340px)] border border-white/10 bg-[linear-gradient(180deg,#1A1A26_50%,#242434_100%)] px-5 pb-6 pt-4 text-center shadow-[0_16px_40px_rgba(0,0,0,0.45)]",onClick:r=>r.stopPropagation(),children:[e("div",{className:"mb-3 flex justify-end",children:e("button",{type:"button",className:"text-2xl leading-none text-[#8E8EA2] transition-colors hover:text-white/80",onClick:N,children:e(O,{})})}),e("h3",{className:"mb-3 text-[16px]/[16px] font-bold text-white",children:l("title__redeem_popup_max")}),e("p",{className:"mx-auto mb-7 max-w-[280px] text-[14px]/[22px] text-white/80",children:l("msg__redeem_limit_reached")}),e(T,{type:"button",variant:"lg",gapBg:"modal",fillColor:"#FABF00",hoverFillColor:"#FABF00",fontSizePx:14,onClick:N,className:"w-full",children:l("btn__ok")})]})}),e(ye,{isOpen:I,onClose:()=>P(!1)})]})};export{Xe 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.