Loading
function(e,t,n){n.d(t,{A:()=>W});var l=n(627968),r=n(64700),i=n(503698),a=n.n(i),s=n(284009),o=n.n(s),u=n(702841),c=n(364840),d=n(228366),p=n(391048),m=n(688810),h=n(176095),A=n(742810),C=n(426398),E=n(558620),y=n(427675),P=n(480642),S=n(722847),_=n(380619),f=n(155984),I=n(683433),T=n(344159),N=n(367921),v=n(174459),g=n(45938),x=n(428262),R=n(259160),M=n(768050),b=n(158032),L=n(830382),j=n(753390),O=n(243217),w=n(652215),D=n(788868);async function U(e){let{onPurchaseAttempt:t,onPurchaseError:n,onPurchaseComplete:l,onPurchaseFinalize:r,hasRedirectURL:i,isGift:a,analyticsLocation:s,analyticsLocations:u,subscriptionPlan:c,planGroup:d,trialId:p,priceOptions:m,paymentSource:h,isPrepaidPaymentPastDue:A,openInvoiceId:C,premiumSubscription:E,onNext:y,metadata:P,sku:S,purchaseType:_,referralCode:f,loadId:I,giftInfoOptions:T,invoicePreview:N,order:v}=e;try{let e,n,r,g;if(t(),i)return;if(_===w.VVm.ONE_TIME)o()(null!=S,"SKU must exist and be fetched."),o()(null!=N,"invoicePreview must exist."),e=await (0,L.XU)(S.applicationId,S.id,{expectedAmount:N.total,expectedCurrency:N.currency,isGift:a,paymentSource:h,loadId:I,giftInfoOptions:T,orderId:v?.id});else{o()(null!=c,"Missing subscriptionPlan"),o()(null!=N,"Missing invoicePreview");let t={amount:N.total,currency:N.currency},n=(0,x.l6)(m,N.checkoutContext?.available_plans),l=(0,x.$Q)((0,x.y8)(c.id,!1,!1,n));if(null!=E){let e=m.currency??N.currency,t=(0,x.Pg)(E,c.id,1,new Set(d));t=(0,x.qn)(t),l=(0,x.UC)(t,e.toLowerCase(),m.paymentSourceId)}if(a){let t=N.total,n=N.currency;e=await (0,L.XU)(D.tv,c.skuId,{expectedAmount:t,expectedCurrency:n,paymentSource:h,subscriptionPlanId:c.id,isGift:!0,loadId:I,giftInfoOptions:T,orderId:v?.id})}else if(A&&null!=C&&null!=h&&null!=E){let n=m.currency??N.currency;e=w.AD1.has(h.type)?await (0,j.LD)(E,C,h,n,I):await (0,j.nV)(E,{paymentSource:h,currency:n},t,l,u,s,I)}else if(null!=E){let n=(0,x.Pg)(E,c.id,1,new Set(d)),r={paymentSource:h,currency:m.currency??N.currency};E.status===w.Dmq.PAUSED&&(r.status=w.Dmq.ACTIVE),E.isPausedAllowsResumeButNotUpdates||(r.items=n),e=await (0,j.nV)(E,r,t,l,u,s,I)}else e=await (0,b.B1)({planId:c.id,currency:m.currency??N.currency,paymentSource:h,trialId:p,metadata:P,referralCode:f,loadId:I,expectedInvoicePrice:t,expectedRenewalPrice:l})}let{shouldReturnEarly:R}=l(e);if(R)return;"subscription"in e?n=null!=e.subscription?O.A.createFromServer(e.subscription):null:"entitlements"in e&&(r=null!=e.entitlements?e.entitlements:void 0),"appliedUserDiscounts"in e&&(g=null!=e.appliedUserDiscounts&&e.appliedUserDiscounts.length>0?e.appliedUserDiscounts:void 0),y(n,r,g)}catch(e){n(e)}finally{r()}}var k=n(566980),G=n(216641),Y=n(999784),F=n(650098);let B=e=>{let{showBackButton:t,onBackClick:n}=e,{premiumSubscription:i,isGift:a,planGroup:s,isPrepaid:o}=e,{buttonLabel:u,analyticsLocations:c,application:d,hasAcceptedTerms:p,paymentSourceId:m,activeSubscription:h,devShelfFetchState:A,hasPaymentSources:C}=(0,N.Ke)({premiumSubscription:i,isGift:a,planGroup:s,isPrepaid:o}),E=r.useMemo(()=>(0,N.X1)(e,{buttonLabel:u,analyticsLocations:c,application:d,hasAcceptedTerms:p,paymentSourceId:m,activeSubscription:h,devShelfFetchState:A,hasPaymentSources:C}),[e,u,c,d,p,m,h,A,C]);return(0,l.jsx)(P.lo,{onBackClick:t?n:void 0,primaryButtonProps:E})};function W(e){let{premiumSubscription:t,onBack:n,onNext:i,legalTermsNodeRef:s,flashLegalTerms:P,invoiceError:b,planError:L,baseAnalyticsData:j,flowStartTime:O,trialId:D,planGroup:W=[],analyticsLocation:H,openInvoiceId:V,metadata:K,backButtonEligible:Z,disablePurchase:q,isTrial:z=!1,onPaymentSourceAdd:$}=e,{selectedSkuId:J,invoicePreview:X,setHasAcceptedTerms:Q,setPurchaseState:ee,contextMetadata:et,paymentSourceId:en,setPurchaseError:el,order:er,priceOptions:ei}=(0,S.t4)(e=>({selectedSkuId:e.selectedSkuId,invoicePreview:e.checkoutInvoicePreview,setHasAcceptedTerms:e.setHasAcceptedTerms,setPurchaseState:e.setPurchaseState,setPurchaseError:e.setPurchaseError,contextMetadata:e.contextMetadata,order:e.order,paymentSourceId:e.paymentSourceId,priceOptions:e.checkoutPriceOptions})),{paymentSources:ea}=(0,C.jm)(),{purchaseType:es,referralCode:eo}=(0,M.P5)(),eu=(0,E.A)(),ec=(0,y.gU)(),{isGift:ed,selectedGiftStyle:ep,customGiftMessage:em,emojiConfetti:eh,soundEffect:eA,giftRecipient:eC,selectedGiftingPromotionReward:eE}=(0,R.Pv)(),ey=(0,_.Mq)(eu),eP=(0,g.lo)(eC),eS={};eS.gift_style=ep,eS.reward_sku_ids=ey&&null!=eE?[eE]:[],eP===g.tB.CUSTOM_MESSAGE_EMOJI_SOUNDBOARD&&(o()(null!=eC,"Gift recipient must be set at purchase review step for these gift options."),eS.recipient_id=eC.id,eS.custom_message=em,eS.emoji_id=eh?.id,eS.emoji_name=eh?.id==null?eh?.surrogates:void 0,eS.sound_id=eA?.soundId);let e_=eu?.id,{analyticsLocations:ef}=(0,m.Ay)(),eI=(0,G.W)(ea,en),eT=(0,u.bG)([h.A],()=>h.A.getBalance(en??""),[en]),eN=null!=eT?eT.amount:null,ev=null!=eT?eT.currency:null,[eg,ex]=r.useState(!1),[eR,eM]=r.useState(!1),{hasEntitlements:eb}=(0,T.X)(e_,ed),eL=(0,x.J$)(ei.paymentSourceId),ej=(0,f.l)(),eO=null;es===w.VVm.ONE_TIME&&(o()(null!=J,"SKU must be selected for one-time purchases"),eO=ec[J]??null,o()(null!=eO,"SKU must exist and be fetched."));let ew=r.useCallback(()=>{ee(k.h.PURCHASING),Q(!0),ex(!0),d.h.wait(p.ET),el(null),v.default.track(w.HAw.PAYMENT_FLOW_COMPLETED,{...j,subtotal:X?.subtotal,tax:X?.tax,expected_amount:X?.total,expected_currency:X?.currency,duration_ms:Date.now()-O,gift_card_balance:eN,gift_card_currency:ev})},[ee,Q,el,j,O,X,eN,ev]),eD=r.useCallback(e=>{ee(k.h.FAIL),el(e),v.default.track(w.HAw.PAYMENT_FLOW_FAILED,{...j,payment_error_code:e?.code,payment_source_id:eI?.id,payment_source_type:eI?.type,duration_ms:Date.now()-O,gift_card_balance:eN,gift_card_currency:ev})},[ee,el,j,O,eI,eN,ev]),eU=r.useCallback(e=>e.redirectConfirmation?(eM(null!=e.redirectURL),{shouldReturnEarly:!0}):(ee(k.h.COMPLETED),{shouldReturnEarly:!1}),[ee]),ek=r.useCallback(()=>{eR||ex(!1)},[eR]),eG=async()=>{await U({onPurchaseAttempt:ew,onPurchaseError:eD,onPurchaseComplete:eU,onPurchaseFinalize:ek,hasRedirectURL:eR,isGift:ed,analyticsLocation:H,analyticsLocations:ef,subscriptionPlan:eu,planGroup:W,trialId:D,priceOptions:ei,paymentSource:eI,isPrepaidPaymentPastDue:ej,openInvoiceId:V,premiumSubscription:t,onNext:i,metadata:K,sku:eO,purchaseType:es,referralCode:eo,loadId:et.loadId,giftInfoOptions:eS,invoicePreview:X,order:er})},eY=(0,A.D7)({location:"PaymentModalReviewStepFooter"}),eF=null!=V||es===w.VVm.ONE_TIME&&!ed,eB=Z&&!eF,eW={legalTermsNodeRef:s,invoiceError:b,planError:L,disablePurchase:q,flashLegalTerms:P,isSubmitting:eg,premiumSubscription:t,isGift:ed,planGroup:W,isPrepaid:eL,isTrial:z,makePurchase:eG,needsPaymentSource:null==eI&&!eb,onNext:i,onPaymentSourceAdd:$};return eY?(0,l.jsx)(B,{...eW,selectedSkuId:J,showBackButton:eB,onBackClick:n}):(0,l.jsx)(c.j,{children:(0,l.jsxs)("div",{className:a()(F.eT,{[F.U3]:eB}),children:[eB?(0,l.jsx)("div",{className:F.aX,children:(0,l.jsx)(I.A,{onClick:n})}):null,(0,l.jsx)(Y.A,{}),(0,l.jsx)(N.Ay,{...eW})]})})}}