Build 603132stable
Module 87725
13,075 characters · in no known chunkDependencies
Required by (56)
11939257433182338785526356949473663134638149346169801195269202475264609266060340034377058400612424171427675463376465657469155473617480642482132558620559260577381580133626797649791655857666646667648699595708791735305746793750532766383771566773882803694806677809029818824845012852607901930908166951305958720970904982291987666994143
Lazily required by (0)none
Requires (20)
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{y0:()=>U,Ni:()=>w,t4:()=>x,Q9:()=>G,y$:()=>k});var i=n(462180),r=n(882035),a=n(315069),s=n(570221),l=n(737291),o=n.n(l),d=n(580630);function c(e){return new(o())(e.amount).dividedBy(10**e.exponent).toNumber()}class u extends a.A{id;quantity;price;total;addOnPlans;static createFromServer(e){return new u({id:e.id,quantity:e.quantity,price:e.price,total:e.total,addOnPlans:e.add_on_plans??[]})}constructor(e){super(),this.id=e.id,this.quantity=e.quantity,this.price=e.price,this.total=e.total,this.addOnPlans=e.addOnPlans??[]}getPlanQuantities(){let e=new Map([[this.id,this.quantity]]);for(let t of this.addOnPlans)e.set(t.id,(e.get(t.id)??0)+t.quantity);return e}matchesItems(e){var t=this.getPlanQuantities(),n=function(e){let t=new Map;for(let{planId:n,quantity:i}of e)t.set(n,(t.get(n)??0)+i);return t}(e);if(t.size!==n.size)return!1;for(let[e,i]of t)if(n.get(e)!==i)return!1;return!0}getPriceString(){var e;return e=this.total,(0,d.$g)(c(e),e.currency,{convertToMajorUnits:!1})}getAddOnPrice(){if(0===this.addOnPlans.length)return null;let{currency:e,exponent:t}=this.addOnPlans[0].price;return{majorUnits:c({currency:e,exponent:t,amount:this.addOnPlans.reduce((e,t)=>e+t.price.amount*t.quantity,0)}),currency:e}}}class _ extends a.A{paymentSources;storeCountry;allowedCurrencies;availablePlans;static createFromOrder(e){let t=e?.checkout_context;return null==t?null:new _({paymentSources:t.payment_sources??[],storeCountry:null!=t.store_country?t.store_country.country:null,allowedCurrencies:t.allowed_currencies??[],availablePlans:(t.available_plans??[]).map(u.createFromServer)})}constructor(e){super(),this.paymentSources=e.paymentSources??[],this.storeCountry=e.storeCountry??null,this.allowedCurrencies=e.allowedCurrencies??[],this.availablePlans=e.availablePlans??[]}getAvailablePlanForItems(e){return this.availablePlans.find(t=>t.matchesItems(e))??null}}class E extends a.A{subscriptionId;subscriptionPreview;updateType;resetBillingCycle;static createFromServer(e){var t,n;return null==e?null:new E({subscriptionId:e.subscription_id??null,subscriptionPreview:null==(t=e.subscription_preview)?null:{currency:t.currency,countryCode:t.country_code,subscriptionTrialId:t.subscription_trial_id??null,renewalInfo:null==(n=t.renewal_info)?null:{price:n.price,currency:n.currency,renewalLineItems:(n.renewal_line_items??[]).map(e=>({refOrderLineItemId:e.ref_order_line_item_id,price:e.price}))},subscriptionType:t.subscription_type??null},updateType:e.update_type??null,resetBillingCycle:e.reset_billing_cycle??!1})}constructor(e){super(),this.subscriptionId=e.subscriptionId??null,this.subscriptionPreview=e.subscriptionPreview??null,this.updateType=e.updateType??null,this.resetBillingCycle=e.resetBillingCycle??!1}}var A=n(818348);class h extends a.A{paymentGateway;paymentSourceId;currency;invoicePreview;static createFromOrder(e){let t=e.billing_facet;return null==t?null:new h({paymentGateway:t.payment_gateway,paymentSourceId:t.payment_source_id??null,currency:t.currency??null,invoicePreview:s.Y.createInvoiceFromOrder(e)})}constructor(e){super(),this.paymentGateway=e.paymentGateway,this.paymentSourceId=e.paymentSourceId??null,this.currency=e.currency??null,this.invoicePreview=e.invoicePreview??null}get fiatCurrency(){return this.paymentGateway===A.kM.VIRTUAL_CURRENCY?null:this.currency}}class I extends a.A{id;status;revision;orderLineItems;billingFacetRecord;externalGatewayFacet;giftingFacet;subscriptionFacet;checkoutContextRecord;createdAt;unsatisfiedConstraints;static createFromServer(e){return new I({id:e.id,status:e.status,revision:e.revision,orderLineItems:e.order_line_items,billingFacetRecord:h.createFromOrder(e),externalGatewayFacet:e.external_gateway_facet??null,giftingFacet:e.gifting_facet??null,checkoutContextRecord:_.createFromOrder(e),createdAt:e.created_at,unsatisfiedConstraints:e.unsatisfied_constraints??[],subscriptionFacet:E.createFromServer(e.subscription_facet)})}constructor(e){super(),this.id=e.id,this.status=e.status,this.revision=e.revision,this.orderLineItems=e.orderLineItems??[],this.billingFacetRecord=e.billingFacetRecord??null,this.externalGatewayFacet=e.externalGatewayFacet??null,this.giftingFacet=e.giftingFacet??null,this.subscriptionFacet=e.subscriptionFacet??null,this.checkoutContextRecord=e.checkoutContextRecord??null,this.createdAt=e.createdAt,this.unsatisfiedConstraints=e.unsatisfiedConstraints??[]}getInvoicePreview(){return null==this.billingFacetRecord?null:this.billingFacetRecord.invoicePreview}firstUnsatisfiedConstraintReasonCode(){return this.unsatisfiedConstraints.length>0?this.unsatisfiedConstraints[0].reason_code:null}}var f=n(566980),p=n(511484),T=n(786300),m=n(815545),g=n(826469),S=n(158045),N=n(202541);function C(e,t){return null!=e&&null!=e.checkout_context?e.checkout_context:null!=t&&null!=t.checkoutContext?t.checkoutContext:null}function O(e){return null==e?{isPremiumPurchase:!0,isPremiumGroupPurchase:!1}:{isPremiumPurchase:(0,S.ys)(e),isPremiumGroupPurchase:e===N.gD.PREMIUM_GROUP_MONTH}}function R(e,t){if(null==e)return null;if("subscription_checkout_invoice_get_request"===e.type)return e;let n=t().contextMetadata.loadId;return e.params.loadId!==n?{...e,params:{loadId:n,...e.params}}:e}var L=n(652215),y=n(504275),D=n(219538),v=n(811315),b=n.n(v),M=n(75304),P=n(65258);let U=1,[w,G]=(0,T.A)();function x(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.x;return G()(e,t)}function k(e){let{checkoutInitParameters:t,startingValues:n,contextMetadata:a,order:s,initialPaymentSourceId:l,initialCurrency:o}=e;return(0,r.h)((e,i)=>{let r,d,c,u=(r={checkoutContext:null,checkoutPaymentSources:[]},{isPremiumPurchase:()=>O(i().selectedPlanId).isPremiumPurchase,isPremiumGroupPurchase:()=>O(i().selectedPlanId).isPremiumGroupPurchase,selectedPlanAttributes:()=>O(i().selectedPlanId),premiumDiscountOffer:()=>i().premiumDiscountInfo.discountOffer??null,premiumDiscountPercent:()=>{let e=i().premiumDiscountInfo.discountOffer;return null!=e?e.discount.amount:null},isPremiumDiscountAppliedToCheckoutInvoice:()=>{let{discountOffer:e}=i().premiumDiscountInfo,t=i().checkoutInvoicePreview;return null!=e&&null!=e.discount&&null!=t&&(0,m.Ro)(t,e.discount.id)},isCheckoutInvoicePreviewLoading:()=>{let e=i().fetchCheckoutInvoicePreviewRequest,t=null==i().checkoutInvoicePreview&&null==i().checkoutInvoiceError;return null!=e&&t},checkoutContext:()=>{let{order:e,checkoutInvoicePreview:t}=i();return C(e,t)},hasCheckoutContextLoaded:()=>null!=i().get("checkoutContext"),checkoutStoreCountry:()=>{let e=i().get("checkoutContext");return null==e?null:null!=e.store_country?e.store_country.country:null},checkoutSelectedCurrency:()=>i().checkoutPriceOptions.currency??null,checkoutPaymentSources:()=>{let e=i().get("checkoutContext");e!==r.checkoutContext&&(r.checkoutContext=e,r.checkoutPaymentSources=null==e||null==e.payment_sources?[]:e.payment_sources.map(g.A.createFromCheckoutContext));return r.checkoutPaymentSources},checkoutSelectedPaymentSource:()=>{let{get:e,paymentSourceId:t}=i();return e("checkoutPaymentSources").find(e=>e.id===t)??null},hasFiatCheckoutPaymentSources:()=>i().get("checkoutPaymentSources").some(e=>e.type!==L.hes.TDS_WALLET&&e.type!==L.hes.UNKNOWN),isCheckoutDataLoading:()=>{let{order:e,checkoutInvoicePreview:t,checkoutInvoiceError:n,purchasePreviewError:r}=i();return null==n&&null==r&&(null==t||null==C(e,t))},primaryInvoicesError:()=>i().checkoutInvoiceError??i().renewalInvoiceError,isOrderLocked:()=>{let{order:e,isOrderSyncing:t}=i();return null!=e&&t}});return{...(0,y.p)(e,i,t),...{startedPaymentFlowWithPaymentSources:n.startedPaymentFlowWithPaymentSources,startingPremiumSubscriptionPlanId:n.startingPremiumSubscriptionPlanId,startingFractionalPremiumEndsAt:null,captureStartingPremiumSubscriptionPlanId:t=>{null==i().startingPremiumSubscriptionPlanId&&e({startingPremiumSubscriptionPlanId:t})},captureStartingFractionalPremiumEndsAt:t=>{null==i().startingFractionalPremiumEndsAt&&e({startingFractionalPremiumEndsAt:t})},captureStartingPaymentFlowWithPaymentSources:t=>{null==i().startedPaymentFlowWithPaymentSources&&e({startedPaymentFlowWithPaymentSources:t})},startingIsInPastDueCheckout:null,setStartingIsInPastDueCheckout:t=>{null==i().startingIsInPastDueCheckout&&e({startingIsInPastDueCheckout:t})}},...{fetchSetupIntentRequestKey:null,fetchSetupIntentPromise:null,getOrCreateSetupIntent:function(t){let{forceRecreate:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=JSON.stringify(t),{fetchSetupIntentRequestKey:a,fetchSetupIntentPromise:s,clearFetchSetupIntent:l}=i();if(!n&&null!=s&&a===r)return s;let o=(0,D.w)({body:t});return e({fetchSetupIntentRequestKey:r,fetchSetupIntentPromise:o}),o.catch(()=>{i().fetchSetupIntentPromise===o&&l()}),o},clearFetchSetupIntent:()=>{e({fetchSetupIntentRequestKey:null,fetchSetupIntentPromise:null})},linkWalletEnabled:!0,setLinkWalletEnabled:t=>{e({linkWalletEnabled:t})}},...{expressCheckoutSubmitting:!1,setExpressCheckoutSubmitting:t=>e({expressCheckoutSubmitting:t}),getShouldUseStripeExpressCheckout:()=>{let e=i().getSharedTenantParams();return!!(0,P.l)()&&null!=e&&!!e.shouldUseStripeExpressCheckout}},...(d=[],c={premiumPlanOptions:null},{getShouldDisallowPlanSelection:()=>{let e=i().getTenantParams(M.C.PREMIUM_CHECKOUT);return null!=e&&(e.shouldDisallowPlanSelection??!1)},getIsInOneStepSubscriptionCheckout:e=>{let{isTrial:t,selectedSkuId:n}=e,{isGift:r,selectedSkuId:a,startedPaymentFlowWithPaymentSources:s,getShouldDisallowPlanSelection:l,getShouldUseStripeExpressCheckout:o}=i();return!!(l()||o())||function(e){let{isTrial:t,isGift:n,selectedSkuId:i,startedPaymentFlowWithPaymentSources:r}=e;return!t&&!n&&null!=i&&N.oz.includes(i)&&!!r}({isTrial:t,isGift:r,selectedSkuId:n??a,startedPaymentFlowWithPaymentSources:s})},getVerifiedTrialId:e=>{let{trialId:t}=e,{referralTrialOfferId:n,selectedSkuId:r,get:a}=i(),s=a("isPremiumPurchase"),l=t??n??null,o=null!=l&&l in N.TP?N.TP[l].skus:[];return null!=l&&(!s||o.includes(r))?l:null},getEffectivePlanGroup:e=>{let{planGroup:t}=e,{selectedPlanId:n}=i();if(null!=t&&(null==n||t.includes(n)))return t;if(null!=n){if((0,S.xq)(n))return N.LE;if((0,S.z4)(n))return N.DA}return d},getPremiumPlanOptionsOrNull:()=>{let{selectedSkuId:e,defaultPlanId:t,get:n}=i(),r=n("isPremiumPurchase");try{let n=(0,S.Tm)({skuId:e,isPremium:r,defaultPlanId:t});if(b()(n,c.premiumPlanOptions))return c.premiumPlanOptions;return c.premiumPlanOptions=n,n}catch(e){return null}}}),get:e=>null!=u[e]?u[e]():null,contextMetadata:a,order:s,orderRecord:null!=s?I.createFromServer(s):null,setOrder:t=>e({order:t,orderRecord:I.createFromServer(t),pendingPaymentSourceId:null}),selectedSkuId:void 0,selectedPlanId:void 0,setSelectedSkuId:t=>e({selectedSkuId:t??void 0,quantity:U}),setSelectedPlanId:function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shouldUpdateQuantity:!0},i=t??void 0;return n.shouldUpdateQuantity?e({selectedPlanId:i,quantity:U}):e({selectedPlanId:i})},quantity:U,setQuantity:t=>e({quantity:t}),fetchCheckoutInvoicePreviewRequest:null,setFetchCheckoutInvoicePreviewRequest:t=>e({fetchCheckoutInvoicePreviewRequest:R(t,i)}),checkoutInvoicePreview:null,checkoutInvoiceError:null,setCheckoutInvoicePreview:(t,n)=>e(e=>({checkoutInvoicePreview:t??null,checkoutInvoiceError:n??null,pendingPaymentSourceId:null!=t&&null==e.order?null:e.pendingPaymentSourceId})),fetchRenewalInvoicePreviewRequest:null,setFetchRenewalInvoicePreviewRequest:t=>e({fetchRenewalInvoicePreviewRequest:R(t,i)}),renewalInvoicePreview:null,renewalInvoiceError:null,setRenewalInvoicePreview:(t,n)=>e({renewalInvoicePreview:t??null,renewalInvoiceError:n??null}),premiumDiscountInfo:p.TI,setPremiumDiscountInfo:t=>e({premiumDiscountInfo:t}),entitlementsGranted:[],setEntitlementsGranted:t=>e({entitlementsGranted:t}),hasAcceptedTerms:!1,setHasAcceptedTerms:t=>e({hasAcceptedTerms:t}),checkoutReviewButtonLabel:"",setCheckoutReviewButtonLabel:t=>e({checkoutReviewButtonLabel:t}),paymentSourceId:l,setPaymentSourceId:t=>e({paymentSourceId:t??null}),pendingPaymentSourceId:null,setPendingPaymentSourceId:t=>e({pendingPaymentSourceId:t??null}),hasAddedPaymentSourceThisSession:!1,setHasAddedPaymentSourceThisSession:()=>e({hasAddedPaymentSourceThisSession:!0}),isOrderSyncing:!1,setIsOrderSyncing:t=>e({isOrderSyncing:t}),orderSyncError:null,setOrderSyncError:t=>e({orderSyncError:t??null}),checkoutPriceOptions:{paymentSourceId:l??void 0,currency:o,loaded:!1},setCheckoutPriceOptions:t=>e(e=>({checkoutPriceOptions:{...e.checkoutPriceOptions,...t}})),setCheckoutCurrency:t=>e(e=>({checkoutPriceOptions:{...e.checkoutPriceOptions,currency:t??void 0}})),purchaseState:f.h.WAITING,setPurchaseState:t=>e({purchaseState:t}),appliedUserDiscounts:[],setAppliedUserDiscounts:t=>e({appliedUserDiscounts:t}),purchaseError:null,setPurchaseError:t=>e({purchaseError:t??null}),purchasePreviewError:null,setPurchasePreviewError:t=>e({purchasePreviewError:t??null}),updatedSubscription:null,setUpdatedSubscription:t=>e({updatedSubscription:t}),readySlideId:null,setReadySlideId:t=>e({readySlideId:t??null})}},i.x)}}