Build 589089stable
Module 243217
7,210 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{h:()=>I,A:()=>f});var i=n(284009),r=n.n(i),a=n(315069),s=n(981088),l=n(367888);class o extends a.A{userId;subscriptionId;oldCurrency;oldPrice;newCurrency;newPrice;priceChangeMode;expectedChargeTime;priceChangeId;static createFromServer(e){return new o({userId:e.user_id,subscriptionId:e.subscription_id,oldCurrency:e.old_currency,oldPrice:e.old_price,newCurrency:e.new_currency,newPrice:e.new_price,priceChangeMode:e.price_change_mode,expectedChargeTime:e.expected_charge_time,priceChangeId:e.price_change_id})}constructor(e){super(),this.userId=e.userId,this.subscriptionId=e.subscriptionId,this.oldCurrency=e.oldCurrency,this.oldPrice=e.oldPrice,this.newCurrency=e.newCurrency,this.newPrice=e.newPrice,this.priceChangeMode=e.priceChangeMode,this.expectedChargeTime=e.expectedChargeTime,this.priceChangeId=e.priceChangeId}get isPriceIncrease(){return"PRICE_INCREASE"===this.priceChangeMode||"OPT_OUT_PRICE_INCREASE"===this.priceChangeMode}get isOptOutPriceIncrease(){return"OPT_OUT_PRICE_INCREASE"===this.priceChangeMode}get isPriceDecrease(){return"PRICE_DECREASE"===this.priceChangeMode}get isInFuture(){return this.expectedChargeTime>new Date().toISOString()}}var d=n(723702),c=n(474090),u=n(570221),_=n(652215),E=n(601107),A=n(202541);function h(e){return{id:e.id,planId:e.plan_id,quantity:e.quantity}}class I extends a.A{id;type;items;createdAt;canceledAt;currentPeriodStart;currentPeriodEnd;status;paymentSourceId;paymentGateway;paymentGatewayPlanId;paymentGatewaySubscriptionId;trialId;trialEndsAt;renewalMutations;streakStartedAt;currency;pauseEndsAt;pauseReason;planId;additionalPlans;metadata;latestInvoice;useStorekitResubscribe;price;userId;eligiblePaymentGateways;priceChange;static createFromServer(e){return new I({id:e.id,type:e.type,createdAt:new Date(e.created_at),canceledAt:null!=e.canceled_at?new Date(e.canceled_at):null,currentPeriodStart:new Date(e.current_period_start),currentPeriodEnd:new Date(e.current_period_end),status:e.status,paymentSourceId:e.payment_source_id,paymentGateway:e.payment_gateway,paymentGatewayPlanId:e.payment_gateway_plan_id,paymentGatewaySubscriptionId:e.payment_gateway_subscription_id,trialId:e.trial_id,trialEndsAt:null!=e.trial_ends_at?new Date(e.trial_ends_at):null,items:e.items.map(h),renewalMutations:null!=e.renewal_mutations?{items:e.renewal_mutations.items.map(h),paymentGatewayPlanId:e.renewal_mutations.payment_gateway_plan_id}:null,streakStartedAt:null!=e.streak_started_at?new Date(e.streak_started_at):null,currency:e.currency,pauseEndsAt:null!=e.pause_ends_at?new Date(e.pause_ends_at):null,pauseReason:e.pause_reason,metadata:e.metadata,useStorekitResubscribe:e.use_storekit_resubscribe,price:e.price,userId:e.user_id,...null!=e.latest_invoice?{latestInvoice:u.A.createInvoiceFromServer(e.latest_invoice)}:{},eligiblePaymentGateways:e.eligible_payment_gateways??null,priceChange:null!=e.price_change?o.createFromServer(e.price_change):null})}constructor(e){super(),this.id=e.id,this.type=e.type,this.items=e.items,this.createdAt=e.createdAt,this.canceledAt=e.canceledAt,this.currentPeriodStart=e.currentPeriodStart,this.currentPeriodEnd=e.currentPeriodEnd,this.status=e.status,this.paymentSourceId=e.paymentSourceId,this.paymentGateway=e.paymentGateway,this.paymentGatewayPlanId=e.paymentGatewayPlanId,this.paymentGatewaySubscriptionId=e.paymentGatewaySubscriptionId,this.trialId=e.trialId,this.trialEndsAt=e.trialEndsAt,this.renewalMutations=e.renewalMutations,this.currency=e.currency,this.pauseEndsAt=e.pauseEndsAt,this.pauseReason=e.pauseReason,this.metadata=e.metadata,this.latestInvoice=e.latestInvoice,this.useStorekitResubscribe=e.useStorekitResubscribe,this.price=e.price,this.userId=e.userId,this.streakStartedAt=e.streakStartedAt,this.eligiblePaymentGateways=e.eligiblePaymentGateways,this.priceChange=e.priceChange;const t=this.renewalMutations;let n=e.items[0].planId,i=null;if(e.type===_.rzx.PREMIUM){const r=A.hd[e.items[0].planId],a=r.interval,s=r.intervalCount;n=(0,l.a9)(e.items,a,s),null!=t&&(i=(0,l.a9)(t.items,a,s))}else null!=t&&t.items.length>0&&(i=t.items[0].planId);this.planId=n,this.additionalPlans=e.items.filter(e=>e.planId!==n),null!=t&&null!=i&&(t.planId=i,t.additionalPlans=t.items.filter(e=>e.planId!==i))}getCurrentSubscriptionPlanIdForGroup(e){return this.items.find(t=>e.includes(t.planId))?.planId}get isPremium(){return this.type===_.rzx.PREMIUM}get isACOM(){return this.paymentGateway===_.kM_.APPLE_ADVANCED_COMMERCE}get planIdForCurrencies(){let e;return this.isPremium?(r()(null!=this.planIdFromItems&&""!==this.planIdFromItems,"Premium subscription has no planId for currencies"),e=this.planIdFromItems):e=this.planId,e}get planIdFromItems(){return this.getCurrentSubscriptionPlanIdForGroup(Object.values(A.gD))}get premiumPlanIdFromItems(){return this.getCurrentSubscriptionPlanIdForGroup([...A.JM])}get isPurchasedViaDesktop(){return null==this.paymentGateway}get isPurchasedViaAppleGeneric(){return this.paymentGateway===_.kM_.APPLE_PARTNER||this.isACOM}get isPurchasedViaApple(){return this.paymentGateway===_.kM_.APPLE||this.isACOM}get isPurchasedViaGoogle(){return this.paymentGateway===_.kM_.GOOGLE}get isPurchasedExternally(){return this.isPurchasedViaApple||this.isPurchasedViaGoogle}get isOnPlatformMatchingExternalPaymentGateway(){return this.isPurchasedViaApple&&(0,d.isIOS)()||this.isPurchasedViaGoogle&&(0,s.xv)()}get hasExternalPlanChange(){return this.isPurchasedExternally&&null!=this.renewalMutations&&this.paymentGatewayPlanId!==this.renewalMutations.paymentGatewayPlanId}get hasPremiumNitroMonthly(){return null!=this.items.find(e=>e.planId===A.gD.PREMIUM_MONTH_TIER_2)}get isBoostOnly(){return this.items.every(e=>[A.gD.PREMIUM_MONTH_GUILD,A.gD.PREMIUM_YEAR_GUILD].includes(e.planId))}get isPausedOrPausePending(){return _.Uyk.ALL_PAUSE.has(this.status)}get isPaused(){return this.status===_.Dmq.PAUSED}get isPausedForFractionalPremium(){return this.status===_.Dmq.PAUSED&&this.pauseReason===E.qf.FRACTIONAL_PREMIUM}get isPausedAllowsUpdatesButNotResume(){return this.status===_.Dmq.PAUSED&&E.FZ.CAN_MAKE_SUBSCRIPTION_UPDATES.has(this.pauseReason)}get isPausedAllowsResumeButNotUpdates(){return this.status===_.Dmq.PAUSED&&(null===this.pauseReason||!E.FZ.CAN_MAKE_SUBSCRIPTION_UPDATES.has(this.pauseReason))}get isEnded(){return this.status===_.Dmq.ENDED}get endedAt(){return this.status!==_.Dmq.ENDED?null:this.metadata?.ended_at!=null?new Date(this.metadata.ended_at):this.currentPeriodEnd}get isActive(){return this.status===_.Dmq.ACTIVE}get statusAllowsPerks(){return _.Uyk.ALLOW_PERKS.has(this.status)}get hasActiveTrial(){return null!=this.trialId&&null!=this.trialEndsAt&&new Date<this.trialEndsAt}get hasActiveDiscount(){if(null==this.metadata)return!1;let e=this.metadata.active_discount_id,t=this.metadata.active_discount_expires_at;return null!=e&&null!=t&&new Date<=new Date(t)}get premiumSince(){return this.streakStartedAt??this.createdAt}get hasAnyPremiumNitro(){return this.items.some(e=>A.JM.has(e.planId))}get hasAnyPremiumGroup(){return this.items.some(e=>e.planId===A.gD.PREMIUM_GROUP_MONTH)}hasPremiumAtLeast(e){return!!this.isPremium&&this.items.some(t=>{let n=A.hd[t.planId];return(0,c.CC)(n.premiumType,e)})}}let f=I}