Loading
function(e,t,n){"use strict";n.d(t,{Y:()=>C});var l=n(627968),i=n(64700),s=n(284009),r=n.n(s),a=n(304072),o=n(606267),u=n(166532),c=n(166926),d=n(482132),m=n(615310),h=n(216641),p=n(364995),f=n(426398),g=n(666646),E=n(211159),A=n(26279);function C(e){let{customFooterProps:t,onFooterBackClick:n,isBackButtonEligible:s,subscriptionMetadata:C,renderStepBody:x,resolveInternalState:I,handleStepChange:_,openInvoiceId:S,analyticsData:y,analyticsLocation:v}=e,{activeSubscription:T,paymentSourceId:N,purchasePreviewError:j,customCheckoutFlow:b,contextMetadata:R,purchaseError:P,setCheckoutCurrency:L}=(0,E.t4)(e=>({activeSubscription:e.activeSubscription,customCheckoutFlow:e.customCheckoutFlow,contextMetadata:e.contextMetadata,paymentSourceId:e.paymentSourceId,purchasePreviewError:e.purchasePreviewError,purchaseError:e.purchaseError,setCheckoutCurrency:e.setCheckoutCurrency})),M=(0,m.bB)();r()(null!=M,"Step should be set");let O=i.useRef(null),[w,k]=(0,a.A)(!1,500),{paymentSources:D}=(0,f.jm)(),{checkoutPaymentSources:U,hasInvoiceOrderContextLoaded:G}=(0,p.t)(),F=(0,g.sw)(),V=(0,h.W)(D,N),B=i.useMemo(()=>{if(null==N)return!1;if(!G)return!0;let e=U.find(e=>e.id===N);return null!=e&&!e.enabled},[U,G,N]),H=(0,o.iB)({checkoutPaymentSources:U,paymentSourceId:N,location:"CheckoutBaseReviewStep"}),{disablePurchase:W}=i.useMemo(()=>{let e={disablePurchase:H||b===A.uH.DEV_STORYBOOK_CHECKOUT};return null!=I?I(e,{paymentSource:V,paymentSourceId:N,isSelectedPaymentSourceDisabled:B,invoicePreview:F,purchasePreviewError:j}):e},[I,V,N,B,F,j,H,b]);i.useEffect(()=>{null!=P&&null!=O.current&&O.current.scrollIntoView({behavior:"smooth"})},[P]);let K=i.useRef(null),Y=(0,g.mx)(),z=i.useCallback(()=>{L(void 0),n()},[L,n]),Z=i.useCallback(()=>{_(u.pn.ADD_PAYMENT_STEPS)},[_]),q=i.useMemo(()=>({hasLegalTermsFlash:w,legalTermsNodeRef:K}),[w,K]),$=i.useMemo(()=>x({handlePaymentSourceAdd:Z},q),[x,Z,q]),J=(0,l.jsx)(c.U,{premiumSubscription:T??null,invoiceError:Y,onBack:z,legalTermsNodeRef:K,flashLegalTerms:()=>k(!0),flowStartTime:R.startTime,onPaymentSourceAdd:Z,disablePurchase:W,analyticsLocation:v,baseAnalyticsData:y,openInvoiceId:S,handleStepChange:_,postPurchaseStep:u.pn.CONFIRM,backButtonEligible:s,metadata:C,...t});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(d.dZ,{children:$}),(0,l.jsx)(d.UX,{children:J})]})}}