Loading
function(e,t,o){o(321073);var n=o(477900),i=o(582128),l=o(115560),r=o(192308),a=o(231723),s=o(73153),C=o(166532),u=o(925847),c=o(310829),p=o(505274),d=o(129230),h=o(998312),_=o(145659),k=o(241440),S=o(700304),f=o(982291),m=o(615456),E=o(331611),w=o(169797),T=o(260273),g=o(652215);o(322076);var O=o(682901),y=o(792996);let I={[h.C.ORB_CHECKOUT]:{allowGiftCustomization:!1,excludePaymentAuthSteps:!0,predicateStepType:"unified"},[h.C.COLLECTIBLES_CHECKOUT]:{allowGiftCustomization:!0,predicateStepType:"one_time_payment"},[h.C.SLAYER_STOREFRONT_CHECKOUT]:{allowGiftCustomization:!0,predicateStepType:"one_time_payment"},[h.C.PREMIUM_CHECKOUT]:{allowGiftCustomization:!1,predicateStepType:"subscription"},[h.C.INBOUND_PREMIUM_PROMOTION_CHECKOUT]:{allowGiftCustomization:!1},[h.C.PREMIUM_APPS_OTP_CHECKOUT]:{allowGiftCustomization:!0,predicateStepType:"one_time_payment"},[h.C.PREMIUM_APPS_SUBSCRIPTION_CHECKOUT]:{allowGiftCustomization:!1},[h.C.GUILD_BOOST_CHECKOUT]:{allowGiftCustomization:!1},[h.C.GUILD_PRODUCT_CHECKOUT]:{allowGiftCustomization:!1,predicateStepType:"one_time_payment"},[h.C.GUILD_ROLE_CHECKOUT]:{allowGiftCustomization:!1,predicateStepType:"subscription"},[h.C.GAME_SERVER_SUBSCRIPTION_CHECKOUT]:{allowGiftCustomization:!1,predicateStepType:"subscription"},[h.C.PAST_DUE_MAGIC_LINK_CHECKOUT]:{allowGiftCustomization:!1}},F=(0,i.lazy)(()=>Promise.all([o.e(339384),o.e(154791),o.e(725246),o.e(476375),o.e(208430)]).then(o.bind(o,427325)).then(e=>{let{UnifiedCheckoutInstance:t}=e;return{default:t}}));function P(e){return(0,n.jsx)(F,{...e})}class U{checkoutFlow;checkoutFlowConfiguration;tenantCheckoutFlowConfig;internalCheckoutFlowControls;override_analytic_params;constructor({checkoutFlow:e}){this.checkoutFlow=e;let t=S.Y[e];if(null==t||!t.implemented||t.flowType!==e)throw Error(`Checkout flow ${e} is not implemented`);this.checkoutFlowConfiguration=t,this.tenantCheckoutFlowConfig=t.TENANT_CHECKOUT_FLOW_CONFIG,this.internalCheckoutFlowControls=I[e],this.override_analytic_params=this.tenantCheckoutFlowConfig.TENANT_PROVIDER_CONFIGS.overrideAnalyticParams}getCheckoutStep(e){return this.tenantCheckoutFlowConfig.CHECKOUT_STEPS[e]}generateRenderHeader(){let{CustomHeaderComponent:e}=this.tenantCheckoutFlowConfig;if(null!=e)return t=>{let{handleClose:o,step:i}=t;return(0,n.jsx)(e,{onClose:o,step:i})}}getPredicateStepConfig(){let{CUSTOM_PREDICATE_STEP_CONFIG:e}=this.tenantCheckoutFlowConfig,{predicateStepType:t}=this.internalCheckoutFlowControls;return null!=e?{key:null,renderStep:e.renderStep,options:e.options}:"one_time_payment"===t?m.kO:"subscription"===t?m.r3:{key:null,renderStep:e=>(0,n.jsx)(E.e,{paymentModalStepProps:e,defaultStep:C.pn.REVIEW})}}getAddPaymentStepConfig(e){let{isGift:t}=e,{allowGiftCustomization:o}=this.internalCheckoutFlowControls;if(this.checkoutFlow!==h.C.ORB_CHECKOUT)return{key:C.pn.ADD_PAYMENT_STEPS,renderStep:e=>(0,n.jsx)(f.c,{checkoutFlow:this.checkoutFlow,paymentModalStepProps:e,returnStep:C.pn.REVIEW,isGiftCustomizationEnabled:t&&o}),options:{renderHeader:!0}}}getGiftCustomizationStepConfig(e){let{isGift:t}=e,{allowGiftCustomization:o}=this.internalCheckoutFlowControls,i=this.getCheckoutStep(C.pn.GIFT_CUSTOMIZATION);if(t&&o&&null!=i)return{key:C.pn.GIFT_CUSTOMIZATION,renderStep:e=>(0,n.jsx)(i,{...e}),options:{modalSizeGetter:()=>"xl",useBreadcrumbLabel:()=>y.intl.string(y.t["W685+b"])}}}getReviewStepConfig(){let e=this.getCheckoutStep(C.pn.REVIEW);return{key:C.pn.REVIEW,renderStep:t=>(0,n.jsx)(e,{...t}),options:{useBreadcrumbLabel:()=>y.intl.string(y.t.QBnNHq)}}}createDefinedStepConfigsArray(e){return e.filter(e=>null!=e)}generateCheckoutStepConfigs(e){let{isGift:t}=e,{CUSTOM_CONFIRM_STEP_CONFIG:o,STEPS_BEFORE_CHECKOUT:n=[]}=this.tenantCheckoutFlowConfig,{excludePaymentAuthSteps:i}=this.internalCheckoutFlowControls,l=this.getPredicateStepConfig(),r=this.getGiftCustomizationStepConfig({isGift:t}),a=this.getAddPaymentStepConfig({isGift:t}),s=this.getReviewStepConfig(),u=this.createDefinedStepConfigsArray([l,...null!=r?[r]:[],...n,a,...i?[]:m.PL,s]);return null!=o&&u.push({key:C.pn.CONFIRM,renderStep:o.renderStep,options:o.options}),u}getApplicationId(e){return this.checkoutFlow===h.C.ORB_CHECKOUT&&null!=e?(0,c.P)(e):this.checkoutFlow===h.C.COLLECTIBLES_CHECKOUT?g.FYj:this.checkoutFlow===h.C.PREMIUM_CHECKOUT?O.tv:void 0}trackPaymentFlowCanceled(e){let{loadId:t,skuId:o,skuProductLine:n,applicationId:i,discoverySessionId:l,analyticsLocation:r,analyticsLocations:a,analyticsObject:s,analyticsSourceLocation:C,isGift:u,eligibleForTrial:c}=e,k=p.A.balance;d.default.track(g.HAw.PAYMENT_FLOW_CANCELED,{load_id:t,discovery_session_id:l,payment_type:g.frM[this.checkoutFlowConfiguration.purchaseType],is_gift:u,sku_id:o,sku_product_line:n,application_id:i,location:r??s,location_stack:a,source:C,eligible_for_trial:c,payment_modal_version:"v2",checkout_design:_.r.UNIFIED,checkout_flow:this.checkoutFlow,virtual_currency_balance:k,...this.checkoutFlow===h.C.PREMIUM_CHECKOUT?{subscription_type:g.rzx.PREMIUM}:{},...this.override_analytic_params})}getStandaloneLoadId(){return(0,u.A)()??(0,l.A)()}renderCheckoutInstance(e){let{giftContextProps:t,checkoutHandlers:{onComplete:C,onClose:u}={},checkoutConfiguration:{skuId:c,skuProductLine:p,discoverySessionId:d,applicationId:h,activeSubscription:_},sharedCheckoutParams:S=T.iz,unifiedCheckoutProviderProps:{analyticsLocations:f,analyticsSourceLocation:m},forwardedPaymentModalProps:{analyticsObject:E,...g}={},tenantParams:O}=e,y=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"modal",I=arguments.length>2?arguments[2]:void 0,F=arguments.length>3?arguments[3]:void 0,U={current:F??(0,l.A)()},R={current:null},{modalKey:M}=I,A=this.generateRenderHeader(),G=h??this.getApplicationId(c),H=!!(null!=t&&t.isGift),b=!1,K={...g,checkoutFlow:this.checkoutFlow,checkoutFlowConfiguration:this.checkoutFlowConfiguration,tenantCheckoutFlowConfig:this.tenantCheckoutFlowConfig,stepConfigs:this.generateCheckoutStepConfigs({isGift:H}),onComplete:e=>{null!=C&&C(e),b=!0},onClose:u,renderHeader:A,skuId:c??null,tenantParams:O??{},loadId:U.current,onOrderCreated:function(e){U.current=e.id,R.current=e},discoverySessionId:d,activeSubscription:_??null,sharedCheckoutParams:S,applicationId:G,analyticsLocations:f,analyticsObject:E,analyticsSourceLocation:m,giftContextProps:t};if("modal"===y)return(0,r.mM)(async()=>{let{UnifiedCheckoutInstance:e}=await Promise.all([o.e(339384),o.e(154791),o.e(725246),o.e(476375),o.e(208430)]).then(o.bind(o,427325));return t=>(0,n.jsx)(e,{...K,renderModalProps:t})},{...I,onCloseRequest:()=>{null!=I.onCloseRequest&&I.onCloseRequest(b,U.current),I.skipCloseModalOnCloseRequest||(0,r.Oo)(M,I.contextKey)},onCloseCallback:()=>{s.h.dispatch({type:"CHECKOUT_MODAL_CLOSE",didSucceed:b}),b||((0,k.S)({checkoutSucceeded:b,order:R.current}),this.trackPaymentFlowCanceled({loadId:U.current,skuId:c,skuProductLine:p,applicationId:G,discoverySessionId:d,analyticsLocation:g.analyticsLocation,analyticsLocations:f,analyticsObject:E,analyticsSourceLocation:m,isGift:H,eligibleForTrial:null!=S.trialId})),null!=I.onCloseCallback&&I.onCloseCallback(b),null!=u&&u(b,c)},modalKey:M});{let e=g.paymentModalOnClose??u,t={transitionState:a.ip.ENTERED,onClose:()=>(null!=e&&e(!1),Promise.resolve())};return(0,n.jsx)(i.Suspense,{fallback:(0,n.jsx)(w.KT,{}),children:(0,n.jsx)(P,{...K,paymentModalOnClose:e,renderModalProps:t})})}}openCheckoutModal(e){let{modalAPIOptions:t}=e;return this.renderCheckoutInstance(e,"modal",t)}renderStandaloneCheckout(e,t){return this.renderCheckoutInstance(e,"standalone",{modalKey:"standalone-checkout"},t)}}let R=529845==o.j?i.memo(function(e){let{checkoutFlow:t,params:o}=e,n=i.useMemo(()=>new U({checkoutFlow:t}),[t]),[l]=i.useState(()=>n.getStandaloneLoadId());return n.renderStandaloneCheckout(o,l)}):null;o.d(t,{},{j9:R,od:U})}