Loading
function(e,t,n){"use strict";n.d(t,{Aj:()=>_,EX:()=>A,NY:()=>x,O1:()=>C,T3:()=>v,XU:()=>S,lo:()=>y});var l=n(635358),i=n(636537),s=n(228366),r=n(913122),a=n(136857),o=n(178253),u=n(753390),c=n(977445),d=n(937427),m=n(67480),h=n(739508),p=n(403362),f=n(107351),g=n(371794),E=n(652215);async function A(e,t,n,i){if(null==m.A.get(t)){s.h.dispatch({type:"SKU_FETCH_START",skuId:t});try{let r=(0,c.Fs)(e),a={url:r?E.Rsh.STORE_SKU(t):E.Rsh.STORE_PUBLISHED_LISTINGS_SKU(t),rejectWithError:!1},o={};n===l.g.VARIANTS_GROUP&&(o.variants_return_style=n),i&&(o.include_unpublished=!0),Object.keys(o).length>0&&(a.query=o);let u=await (0,g.aP)(a);s.h.dispatch({type:"SKU_FETCH_SUCCESS",sku:r?u.body:u.body.sku}),r||s.h.dispatch({type:"STORE_LISTING_FETCH_SUCCESS",storeListing:u.body})}catch(e){throw s.h.dispatch({type:"SKU_FETCH_FAIL",skuId:t}),new o.A(`Failed to fetch SKU ${t}`)}}}async function C(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(!(0,c.Fs)(e)&&t)throw Error("this should only be used in test mode");let n=(await (0,g.aP)({url:E.Rsh.APPLICATION_SKUS(e),rejectWithError:!1})).body;return s.h.dispatch({type:"SKUS_FETCH_SUCCESS",skus:n}),n}async function x(e){let{applicationId:t,skuId:n,paymentSourceId:l,isGift:i,currency:s}=e,o={payment_source_id:l,gift:i,currency:s};(0,c.Fs)(t)&&(o.test_mode=!0);let u=d.A.getPromotionIdOverride();null!=u&&(o.promotion_id_override=u);try{return(await (0,g.aP)({url:E.Rsh.STORE_SKU_PURCHASE(n),query:o,oldFormErrors:!0,rejectWithError:!1})).body}catch(t){let e=t instanceof r.Ey?t:new r.Ey(t);if(e.code===a.tG.BILLING_BUNDLE_ALREADY_PURCHASED||e.code===a.tG.BILLING_BUNDLE_PARTIALLY_OWNED||e.code===a.tG.INVALID_BILLING_ADDRESS)throw e;return null}}let I={isGift:!1};async function _(e,t,n,l,a){s.h.dispatch({type:"ORDER_CREATE_START"});try{let r={order_line_items:[{sku_id:e,quantity:1,purchase_type:1}],billing_facet:{payment_source_id:t},location_facet:{request_gateway_country_code:n}};l&&(r.gifting_facet={is_gift:!0,gift_customization:{recipient_id:a.recipient_id,gift_style:a.gift_style,emoji_id:a.emoji_id,emoji_name:a.emoji_name,sound_id:a.sound_id,reward_sku_ids:a.reward_sku_ids,custom_message_contents:a.custom_message}});let o=(await i.Bo.post({url:E.Rsh.ORDER_CREATE,body:r,rejectWithError:!1})).body,u=o.id;return s.h.dispatch({type:"ORDER_CREATE_SUCCESS",orderId:u,order:o}),u}catch(e){throw s.h.dispatch({type:"ORDER_CREATE_FAIL"}),new r.Ey(`Failed to create order: ${e}`)}}async function S(e,t,n){let{paymentSource:l,expectedAmount:o,expectedCurrency:m,analyticsLoadId:g,isGift:A,giftInfoOptions:C,subscriptionPlanId:x,loadId:_,countryCode:S,orderId:y}={...I,...n};s.h.wait(()=>{s.h.dispatch({type:"SKU_PURCHASE_START",applicationId:e,skuId:t})});let v=(0,c.Fs)(e);try{let e={gift:A,sku_subscription_plan_id:x,gateway_checkout_context:await (0,h.ob)(l),load_id:_,gift_info_options:C},n=d.A.getPromotionIdOverride();if(null!=n&&(e.promotion_id_override=n),v)e.test_mode=!0;else{if(null!=l&&(e.payment_source_id=l.id,e.payment_source_token=await (0,u.jV)(l),E.KcG.has(l.type))){let t=await (0,u.jf)(l.type);e.return_url=(0,i.TP)()+E.Rsh.BILLING_POPUP_BRIDGE_CALLBACK_REDIRECT_PREFIX(l.type,t??"","success")}null!=S&&(e.country_code=S)}null!=o&&(e.expected_amount=o),null!=m&&(e.expected_currency=m),e.purchase_token=(0,f.r)(),null!=y&&(e.order_id=y);let r=await i.Bo.post({url:E.Rsh.STORE_SKU_PURCHASE(t),body:e,context:{load_id:g},oldFormErrors:!0,rejectWithError:!1});return s.h.dispatch({type:"SKU_PURCHASE_SUCCESS",skuId:t,libraryApplications:null!=r.body.library_applications?r.body.library_applications.filter(p.Vq):[],entitlements:r.body.entitlements,appliedUserDiscounts:r.body.applied_user_discounts,giftCode:r.body.gift_code}),{...r.body,appliedUserDiscounts:r.body.applied_user_discounts,redirectConfirmation:!1}}catch(i){let n=i instanceof r.Ey?i:new r.Ey(i);if((n.code===a.tG.CONFIRMATION_REQUIRED||n.code===a.tG.AUTHENTICATION_REQUIRED)&&s.h.dispatch({type:"SKU_PURCHASE_AWAIT_CONFIRMATION",skuId:t,isGift:A}),s.h.dispatch({type:"SKU_PURCHASE_FAIL",applicationId:e,skuId:t,error:n}),n.code!==a.tG.CONFIRMATION_REQUIRED)throw n;if(!i.body.payment_id)throw(0,u.i0)("payment id cannot be null on redirected confirmations.");return(0,u.MM)(i.body,l)}}async function y(){try{let e={purchase_token:(0,f.r)()};return{...(await i.Bo.post({url:E.Rsh.STORE_EMAIL_RESEND_PAYMENT_VERIFICATION,body:e,oldFormErrors:!0,rejectWithError:!1})).body}}catch(e){throw e instanceof r.Ey?e:new r.Ey(e)}}function v(){s.h.dispatch({type:"SKU_PURCHASE_CLEAR_ERROR"})}}