Build 589089stable
Module 945960
3,065 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{Vn:()=>A,u1:()=>I,qz:()=>h,_D:()=>E});var i=n(562465),r=n(554146),a=n(228366),s=n(826673),l=n(669316),o=n(594061),d=n(174459),c=n(723702),u=n(38405);(0,n(945810).mj)({name:"2026-06-android-two-week-trials",kind:"user",defaultConfig:{enabled:!1,trialCTAEnabled:!1},variations:{1:{enabled:!0,trialCTAEnabled:!0},2:{enabled:!0,trialCTAEnabled:!1}}}),n(202541);var _=n(652215);async function E(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{offerId:void 0,paymentGatewayOverride:void 0},E=arguments.length>3?arguments[3]:void 0,A=arguments.length>4?arguments[4]:void 0;if(t){a.h.dispatch({type:"BILLING_USER_OFFER_FETCH_START"});try{let t;null!=e&&d.default.track(_.HAw.FETCH_USER_OFFER_STARTED,{call_location:e});let{offerId:h,paymentGatewayOverride:I}=n,f=void 0!==I?I:(t=null,(0,c.isAndroid)()?t=_.kM_.GOOGLE:(0,c.isIOS)()&&(t=_.kM_.APPLE),t),p=await i.Bo.post({url:_.Rsh.USER_OFFER,body:null!=f||null!=h?{payment_gateway:f,offer_id:h}:{},rejectWithError:!0,retries:null!=E?E.retries:void 0}),T=p.body.user_trial_offer??null,m=p.body.user_discount_offer??null;if(null!=h&&null!=m&&m.discount_id!==h){let e=Error("Returned user discount offer does not match offer ID request parameter");throw u.A.captureException(e,{extra:{offer_id:h,user_discount_offer:m},...A}),e}return null==T&&(0,s.k8)(r.M.NAGBAR_NOTICE_PREMIUM_TIER_TWO_TRIAL_ENDING)&&(0,o.xB)(r.M.NAGBAR_NOTICE_PREMIUM_TIER_TWO_TRIAL_ENDING),a.h.dispatch({type:"BILLING_USER_OFFER_FETCH_SUCCESS",userTrialOffer:T,userDiscountOffer:null!=m?l.A.createFromServer(m):null}),!0}catch(e){a.h.dispatch({type:"BILLING_USER_OFFER_FETCH_FAIL"})}}return!1}async function A(){a.h.dispatch({type:"BILLING_USER_OFFER_FETCH_START"});try{let e=(await i.Bo.get({url:_.Rsh.CHURN_USER_OFFER,rejectWithError:!0})).body.offer??null,t=null!=e?l.A.createFromServer(e):null;return a.h.dispatch({type:"BILLING_USER_OFFER_FETCH_SUCCESS",userDiscountOffer:t}),{userDiscountOffer:t}}catch(e){a.h.dispatch({type:"BILLING_USER_OFFER_FETCH_FAIL"})}}async function h(){let e=null;try{let t=(await i.Bo.post({url:_.Rsh.CHURN_USER_OFFER,rejectWithError:!0})).body.offer??null;null!=t&&(e=l.A.createFromServer(t),a.h.dispatch({type:"BILLING_USER_OFFER_FETCH_SUCCESS",userDiscountOffer:e}))}catch(e){}return e}function I(e,t){let n=null!=e&&null==e.expires_at?e.id:void 0,r=null==t||t.hasAcknowledged()?void 0:t.id;if(void 0!==n||void 0!==r)return i.Bo.post({url:_.Rsh.USER_OFFER_ACKNOWLEDGED,body:{user_trial_offer_id:n,user_discount_offer_id:r},oldFormErrors:!0,rejectWithError:!1}).then(e=>{let t=e.body.user_discount??null,n=e.body.user_discount_offer??null;a.h.dispatch({type:"BILLING_USER_OFFER_ACKNOWLEDGED_SUCCESS",userTrialOffer:e.body.user_trial_offer??null,userDiscount:null!=t?l.A.createFromServer(t):null,userDiscountOffer:null!=n?l.A.createFromServer(n):null})}).catch(e=>{404===e.status&&a.h.dispatch({type:"BILLING_USER_OFFER_ACKNOWLEDGED_SUCCESS",userTrialOffer:null,userDiscount:null,userDiscountOffer:null})})}}