1import{g as O,j as u,p as ee,y as V,e as w,h as j,ak as H,bI as Q,c as te,Q as ie,o as y,B as L,a8 as ne,z as se,q as ae,Z as oe,aG as ce,bJ as de,I as M,K as re,H as _e,aJ as le,_ as pe,Y as ue,bK as me,bL as U,O as q,k as be,bM as f,J as he}from"./index-878ce38c.js";import{r as b}from"./react-0e2a0c96.js";import{a as fe}from"./images-0c2231a1.js";import{r as ve}from"./error-d088b380.js";var E=(e=>(e.Default="default",e.BeforeSubmit="before_submit",e.AfterSubmit="after_submit",e.QrNoteBeforeCode="qr_note_before_code",e.QrCodeNote="qr_code_note",e.QrNoteAfterCode="qr_note_after_code",e.NoteAfterFinishButton="note_after_finish_button",e))(E||{});const W=({type:e="default"})=>{const{extra:c}=O();let d=c==null?void 0:c.payment_message;if(!d)return null;e!=="default"&&(d=d[e]);let s="";return typeof d=="string"&&(s=d),s?u("div",{className:ee("link-inside text-text-secondary",{"rounded-md bg-bg-panel p-4 [&_[style*=bold]]:!font-medium [&_[style*=bold]]:text-text-primary [&_strong]:!font-medium [&_strong]:text-text-primary [&_b]:!font-medium [&_b]:text-text-primary text-xs/normal":e==="before_submit","text-xs/normal":e==="default"||e==="after_submit"||e==="note_after_finish_button","text-sm/[22px]":e==="qr_note_before_code"||e==="qr_code_note"||e==="qr_note_after_code"}),dangerouslySetInnerHTML:{__html:s}}):null},ge=()=>{const{onSubmit:e,isValid:c,isSubmitting:d}=V(),{appId:s,channelId:r,isFlashSale:n}=w(),{role:a}=j(),{trackClick:m}=H(),{currentItem:t}=O(),h=Q(),v=n?"flash_sale":h?"main":"confirmation",T=b.useRef(!1);return{onClick:b.useCallback(async l=>{if(!T.current)try{return T.current=!0,m({open_id:a==null?void 0:a.open_id,app_id:s,channel_id:r,...h?{}:{item_id:t==null?void 0:t.item_id,app_point_amount:t==null?void 0:t.app_point_amount,rebate_card_id:t==null?void 0:t.rebate_card_id,app_item_id:t==null?void 0:t.app_item_id,currency_amount:t==null?void 0:t.currency_amount,currency:t==null?void 0:t.currency},event_source:v,action:"init_txn"}),window.gtag("event","msp.init-purchase",{appId:s,channelId:r,...h?{}:{itemId:t==null?void 0:t.item_id,appPointAmount:t==null?void 0:t.app_point_amount,rebateCardId:t==null?void 0:t.rebate_card_id,appItemId:t==null?void 0:t.app_item_id,currencyAmount:t==null?void 0:t.currency_amount,currency:t==null?void 0:t.currency},eventSource:v}),window.fbq("track","InitiateCheckout",{content_category:s,channel_id:r,...h?{}:{content_ids:[t==null?void 0:t.item_id]}}),e(l)}finally{T.current=!1}},[s,r,t,h,e,a==null?void 0:a.open_id,v,m]),isDisabled:!c||d}},Ee=({label:e,className:c,isDisabled:d,hideResError:s=!1})=>{const{isValid:r,isSubmitting:n,resError:a}=V(),{t:m}=te(),{onClick:t,isDisabled:h}=ge(),v=a&&a.message!=="error_limit_age_purchased_exceeded"?ve(a,a.cause,m):"",[T,x]=b.useState(!1);b.useEffect(()=>{x((a==null?void 0:a.message)==="error_limit_age_purchased_exceeded")},[a]);const l=u(ie,{isOpen:T,onClose:()=>x(!1),children:y("div",{className:"max-w-xs rounded-lg bg-bg-popup p-6",children:[u(fe,{className:"mx-auto mb-5 block text-[64px]"}),u("div",{className:"mb-3 text-center text-base/none font-bold text-text-title",children:m("title__topup_limit_exceeded")}),u("div",{className:"mb-5 text-sm/[22px] text-text-secondary",dangerouslySetInnerHTML:{__html:m("msg__topup_limit_exceeded",a==null?void 0:a.cause)}}),u(L,{fluid:!0,height:ne.H40,onClick:()=>x(!1),children:m("btn__ok")})]})});return y(se,{children:[u(W,{type:E.BeforeSubmit}),u(W,{type:E.AfterSubmit}),u(W,{type:E.NoteAfterFinishButton}),y("div",{className:"mt-2",children:[!s&&v&&r&&!n&&u("div",{className:"mb-2 text-sm text-text-content2",children:v}),y(L,{className:c,fluid:!0,onClick:()=>t().catch(()=>{}),isDisabled:d||h,children:[u("span",{children:e||m("btn__proceed_to_payment")}),u("span",{children:n&&"..."})]})]}),u(W,{type:E.Default}),l]})},S=e=>{var c;switch((c=e.invoiceType)==null?void 0:c.id){case f.TW_DONATE:return{type:f.TW_DONATE,data:{donate_num:e.invoiceTWDonateNum==="other"?e.invoiceTWDonateNumOther:e.invoiceTWDonateNum}};case f.TW_PERSONAL:return{type:f.TW_PERSONAL,data:{personal_invoice_type:e.invoiceTWPersonalType,email:e.invoiceTWPersonalEmail,name:e.invoiceTWPersonalName,city:e.invoiceTWPersonalCity,area:e.invoiceTWPersonalArea,address:e.invoiceTWPersonalAddress,barcode:e.invoiceTWPersonalBarcode,id_number:e.invoiceTWPersonalIdNumber}};case f.TW_TRIPLE:return{type:f.TW_TRIPLE,data:{email:e.invoiceTWTripleEmail,name:e.invoiceTWTripleName,city:e.invoiceTWTripleCity,area:e.invoiceTWTripleArea,address:e.invoiceTWTripleAddress,ubn:e.invoiceTWTripleUBN}};case f.MY_INVOICE:return{type:f.MY_INVOICE,data:{email:e.email,name:e.name}};case f.ID_INVOICE:return{type:f.ID_INVOICE,data:{email:e.email}}}};function Ae(e){const{appId:c,isFlashSale:d}=w();let{channelId:s}=w();e&&(s=e);const{eventInfo:r,currentItem:n}=O(),{region:a,lang:m}=ae(),{role:t}=j(),h=(t==null?void 0:t.packed_role_id)||0,{getRevampExperimentData:v}=H(),T=Q(),{refreshPendingTxnCount:x}=oe(),l=b.useCallback(async(i,p,o)=>{var D,F;const{promoCode:_,promoCodeDetails:g,captcha:N,captchaKey:C,friendPlayerId:A,enabledTicketDeduction:I,...R}=i,Z=ce({enabledTicketDeduction:I,promoCodeDetails:g,currentItem:n}),P=de({enabledTicketDeduction:I,promoCodeDetails:g,currentItem:n}),X={app_id:c,packed_role_id:h,channel_id:s,service:(D=M(he))!=null?D:re?"mb":"pc",item_id:T||n==null?void 0:n.item_id,channel_data:p||R,promo_code:g?_:void 0,captcha_key:C||void 0,captcha:N||void 0,event_id:r&&r.eligible_item===(n==null?void 0:n.item_id)?r.id:void 0,player_id:A||void 0,revamp_experiment:v(),is_flash_sale:d||void 0,earned_tickets:Z,selected_tickets:P?(F=n==null?void 0:n.ticket_deduction)==null?void 0:F.deducted_ticket_amount:void 0,...n!=null&&n.dynamic_pricing_item?{promotion_data:{dpi:{rebate_card_id:n.rebate_card_id}}}:void 0};await _e.post("/preflight");try{const k=await le(["/shop/pay/init?region=".concat(a,"&language=").concat(m),X,{headers:{"x-csrf-token":M("__csrf__")}}]);if(k.result!=="success")throw new Error(k.result,{cause:k.error_data});return pe.includes(ue)&&await x().catch(()=>{}),k}catch(k){throw o&&o(),k}}
1,[c,s,n,m,a,h,r,v,T,d,x]),Y=b.useCallback((i,p)=>{const o=S(i);return l(i,{...p,invoice:o})},[l]),K=b.useCallback(async(i,p)=>{const{name:o,email:_,CPF:g,DOB:N,phone:C,agreedSaveUserInfo:A}=i,I={full_name:o,email:_,id_type:1,id_number:g,birthdate:N?me(N):void 0,msisdn:C,delete_user_info:!A,save_user_info:A};return await l(i,{...p,user_info:I})},[l]),J=b.useCallback(async(i,p)=>{const o=S(i),_=(i.useNewCard?i.cardNumber:i.selectedCard.cardDisplayNo).slice(-4);return await l(i,{...p,invoice:o&&{type:U[o.type],data:{...o.data,trailing_digits:_}}})},[l]),$=b.useCallback(async(i,p)=>{const o=S(i);return await l(i,{...p,invoice:o&&{...o,type:U[o.type]}})},[l]),G=b.useCallback((i,p,o=!1)=>{var N,C;const _=(N=i==null?void 0:i.init)==null?void 0:N.url;if(!_)throw new Error(q);const g=p||((C=i.init)==null?void 0:C.params);g?Te(_,g):o?window.open(_,"_blank"):window.location.href=_},[]),B=be(),z=b.useCallback((i,p)=>{var _;const o=p?(_=i==null?void 0:i.exec)==null?void 0:_.display_id:i==null?void 0:i.display_id;if(!o)throw new Error(q);B("/result?display_id=".concat(o))},[B]);return{postInit:l,postInitInvoice:Y,postInitCreditCardTW:J,postInitApplePayTW:$,postInitUserInfoBR:K,redirectInitUrl:G,redirectDisplayId:z}}const Te=(e,c,d="_self")=>{const s=document.createElement("form");s.setAttribute("action",e),s.setAttribute("method","POST"),s.setAttribute("target",d),Object.keys(c).map(r=>{const n=document.createElement("input");n.setAttribute("type","hidden"),n.setAttribute("name",r),n.setAttribute("value",c[r]),s.appendChild(n)}),document.getElementsByTagName("body")[0].appendChild(s),s.submit(),s.parentNode&&s.parentNode.removeChild(s)};export{Ee as P,ge as a,W as b,E as c,Ae as u};
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.