2026-08-05 07:35:12 +00:00
// Module ID: 6754
// Function ID: 6755
2026-07-20 16:05:17 +00:00
// Name: calculateFractionalPremiumInfo
2026-08-05 07:35:12 +00:00
// Dependencies: [32, 19, 1874, 3907, 6755, 676, 1876, 3837, 38, 3916, 3901, 589, 4681, 6756, 12, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-08-05 07:35:12 +00:00
// Module 6754 (calculateFractionalPremiumInfo)
2026-07-23 10:11:24 +00:00
import _slicedToArray from "_slicedToArray" ;
2026-07-29 08:29:29 +00:00
import noop from "noop" ;
import mergeGuildAvatar from "mergeGuildAvatar" ;
import reset from "reset" ;
import addEntitlement from "addEntitlement" ;
2026-07-23 10:11:24 +00:00
import ME from "ME" ;
import GuildFeatures from "GuildFeatures" ;
2026-07-29 08:29:29 +00:00
let c10 ;
let c9 ;
2026-07-23 10:11:24 +00:00
let closure_12 ;
2026-07-29 08:29:29 +00:00
let metroImportAll ;
let unpackModuleId ;
2026-07-23 10:11:24 +00:00
const require = arg1 ;
2026-07-20 16:05:17 +00:00
function calculateFractionalPremiumInfo ( isFetching ) {
let entitlements ;
let excludeReverseTrialFromCountdown ;
let fetchedAllEntitlements ;
let premiumSubscription ;
let unactivatedFractionalPremiumUnits ;
let flag = isFetching . isFetching ;
if ( flag === undefined ) {
flag = false ;
}
( { entitlements , unactivatedFractionalPremiumUnits , premiumSubscription , fetchedAllEntitlements , excludeReverseTrialFromCountdown } = isFetching ) ;
2026-08-05 07:35:12 +00:00
let obj = { isFractionalPremiumActive : false , fractionalState : constants3.NONE , startsAt : importDefault ( 3837 ) ( 0 ) , endsAt : importDefault ( 3837 ) ( 0 ) , currentEntitlementId : "" , currentEntitlementEndsAt : importDefault ( 3837 ) ( 0 ) , unactivatedUnits : [ ] , fetched : fetchedAllEntitlements } ;
2026-07-20 16:05:17 +00:00
if ( flag ) {
obj = { } ;
const merged = Object . assign ( obj ) ;
2026-07-29 08:29:29 +00:00
obj . fetched = false ;
2026-07-20 16:05:17 +00:00
return obj ;
} else {
if ( null != isFetching . currentUser ) {
const found = entitlements . filter ( ( endsAt ) = > null != endsAt . endsAt && null != endsAt . startsAt ) ;
const sorted = found . sort ( ( endsAt , endsAt2 ) = > {
let tmp2 = null != endsAt . endsAt ;
if ( tmp2 ) {
tmp2 = null != endsAt2 . endsAt ;
}
2026-07-29 08:29:29 +00:00
callback ( table [ 8 ] ) ( tmp2 , "endsAt should not be null" ) ;
2026-07-20 16:05:17 +00:00
let num = - 1 ;
if ( endsAt . endsAt >= endsAt2 . endsAt ) {
let num2 = 0 ;
if ( endsAt . endsAt > endsAt2 . endsAt ) {
num2 = 1 ;
}
num = num2 ;
}
return num ;
} ) ;
const reversed = sorted . reverse ( ) ;
if ( sorted . length > 0 ) {
const _Array = Array ;
const mapped = Array . from ( entitlements . values ( ) ) . map ( ( id ) = > id . id ) ;
const arr = Array . from ( entitlements . values ( ) ) ;
2026-07-29 08:29:29 +00:00
obj = { extra : null } ;
const obj1 = { entitlementIds : null } ;
obj1 [ 0 ] = mapped ;
obj [ 0 ] = obj1 ;
2026-08-05 07:35:12 +00:00
const result = require ( 3916 ) /* _createGatewayCheckoutContext */ . captureBillingMessage ( "fractional redemption entitlements should have startsAt/endsAt" , obj ) ;
2026-07-20 16:05:17 +00:00
const _Error = Error ;
const error = new Error ( "fractional redemption entitlements should have startsAt/endsAt" ) ;
throw error ;
}
2026-07-29 08:29:29 +00:00
let first = sorted [ 0 ] ;
if ( first == null ) {
first = null ;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if ( null == first ) {
2026-07-20 16:05:17 +00:00
if ( excludeReverseTrialFromCountdown ) {
let sourceType ;
2026-07-29 08:29:29 +00:00
if ( first != null ) {
sourceType = first . sourceType ;
2026-07-20 16:05:17 +00:00
}
excludeReverseTrialFromCountdown = sourceType === constants . REVERSE_TRIAL ;
}
2026-07-29 08:29:29 +00:00
const obj2 = { isFractionalPremiumActive : null , fractionalState : null , startsAt : null , endsAt : null , currentEntitlementId : null , currentEntitlementEndsAt : null , unactivatedUnits : null , fetched : null } ;
obj2 [ 0 ] = null != first ;
obj2 [ 1 ] = tmp7 ;
if ( null != first ) {
2026-08-05 07:35:12 +00:00
let tmp11 = tmp2 ( 3837 ) ( first . startsAt ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-08-05 07:35:12 +00:00
tmp11 = tmp2 ( 3837 ) ( 0 ) ;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj2 [ 2 ] = tmp11 ;
if ( null != first ) {
2026-08-05 07:35:12 +00:00
const obj4 = require ( 3901 ) /* getPremiumPlanItem */ ;
let tmp2ResultResult = tmp2 ( 3837 ) ( obj4 . extendDateWithUnconsumedFractionalPremium ( first . endsAt , unactivatedFractionalPremiumUnits , undefined , excludeReverseTrialFromCountdown ) ) ;
const tmp2Result = tmp2 ( 3837 ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-08-05 07:35:12 +00:00
tmp2ResultResult = tmp2 ( 3837 ) ( 0 ) ;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj2 [ 3 ] = tmp2ResultResult ;
let str = "" ;
if ( null != first ) {
str = first . id ;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj2 [ 4 ] = str ;
if ( null != first ) {
2026-08-05 07:35:12 +00:00
let tmp18 = tmp2 ( 3837 ) ( first . endsAt ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-08-05 07:35:12 +00:00
tmp18 = tmp2 ( 3837 ) ( 0 ) ;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj2 [ 5 ] = tmp18 ;
obj2 [ 6 ] = unactivatedFractionalPremiumUnits ;
obj2 [ 7 ] = fetchedAllEntitlements ;
2026-07-20 16:05:17 +00:00
return obj2 ;
} else {
if ( null == premiumSubscription ) {
2026-07-29 08:29:29 +00:00
const FP_ONLY = tmp . FP_ONLY ;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const FP_SUB_PAUSED = tmp . FP_SUB_PAUSED ;
2026-07-20 16:05:17 +00:00
}
}
return obj ;
}
}
2026-07-29 08:29:29 +00:00
( { EntitlementSourceTypes : metroImportAll , EntitlementTypes : c9 , SubscriptionStatusTypes : c10 } = ME ) ;
( { FractionalPremiumStates : unpackModuleId , PREMIUM_SUBSCRIPTION_APPLICATION : closure_12 } = GuildFeatures ) ;
let result = require ( "mergeGuildAvatar" ) . fileFinishedImporting ( "modules/billing/hooks/useFractionalPremiumInfo.tsx" ) ;
2026-07-20 16:05:17 +00:00
export default function useFractionalPremiumInfo() {
let excludeReverseTrialFromCountdown ;
2026-07-23 10:11:24 +00:00
let importDefault ;
2026-07-20 16:05:17 +00:00
let obj = arg0 ;
if ( arg0 === undefined ) {
2026-07-23 10:11:24 +00:00
obj = { forceFetch : false , excludeReverseTrial : false , excludeReverseTrialFromCountdown : false } ;
2026-07-20 16:05:17 +00:00
}
const forceFetch = obj . forceFetch ;
2026-07-23 10:11:24 +00:00
( { excludeReverseTrial : importDefault , excludeReverseTrialFromCountdown } = obj ) ;
let stateFromStores ;
let stateFromStoresArray ;
let stateFromStores1 ;
let stateFromStoresArray1 ;
let stateFromStores2 ;
2026-07-20 16:05:17 +00:00
let closure_8 ;
2026-07-23 10:11:24 +00:00
const items = [ stateFromStores1 ] ;
stateFromStores = forceFetch ( excludeReverseTrialFromCountdown [ 11 ] ) . useStateFromStores ( items , ( ) = > stateFromStores1 . getCurrentUser ( ) ) ;
const obj2 = forceFetch ( excludeReverseTrialFromCountdown [ 11 ] ) ;
2026-07-29 08:29:29 +00:00
let tmp = excludeReverseTrialFromCountdown ;
2026-07-23 10:11:24 +00:00
const items1 = [ stateFromStores2 ] ;
stateFromStoresArray = forceFetch ( excludeReverseTrialFromCountdown [ 11 ] ) . useStateFromStoresArray ( items1 , ( ) = > stateFromStores2 . getFractionalPremium ( { excludeReverseTrial : closure_1 } ) ) ;
let obj3 = forceFetch ( excludeReverseTrialFromCountdown [ 11 ] ) ;
const items2 = [ stateFromStores2 ] ;
stateFromStores1 = forceFetch ( excludeReverseTrialFromCountdown [ 11 ] ) . useStateFromStores ( items2 , ( ) = > stateFromStores2 . fetchedAllEntitlements ) ;
const obj4 = forceFetch ( excludeReverseTrialFromCountdown [ 11 ] ) ;
const items3 = [ stateFromStores2 ] ;
stateFromStoresArray1 = forceFetch ( excludeReverseTrialFromCountdown [ 11 ] ) . useStateFromStoresArray ( items3 , ( ) = > stateFromStores2 . getUnactivatedFractionalPremiumUnits ( ) ) ;
const obj5 = forceFetch ( excludeReverseTrialFromCountdown [ 11 ] ) ;
const items4 = [ stateFromStoresArray1 ] ;
stateFromStores2 = forceFetch ( excludeReverseTrialFromCountdown [ 11 ] ) . useStateFromStores ( items4 , ( ) = > stateFromStoresArray1 . getPremiumTypeSubscription ( ) ) ;
2026-07-29 08:29:29 +00:00
let fetchingAllEntitlements = null != stateFromStores ;
if ( fetchingAllEntitlements ) {
fetchingAllEntitlements = ! tmp3 . fetchingAllEntitlements ;
}
if ( fetchingAllEntitlements ) {
let fetchedAllEntitlements = tmp3 . fetchedAllEntitlements ;
let tmp9 = ! fetchedAllEntitlements ;
if ( fetchedAllEntitlements ) {
tmp9 = forceFetch ;
}
fetchingAllEntitlements = tmp9 ;
}
2026-07-20 16:05:17 +00:00
if ( ! fetchingAllEntitlements ) {
2026-07-29 08:29:29 +00:00
fetchingAllEntitlements = tmp3 . fetchingAllEntitlements ;
2026-07-20 16:05:17 +00:00
}
if ( ! fetchingAllEntitlements ) {
2026-07-29 08:29:29 +00:00
let tmp10 = null != stateFromStores ;
if ( tmp10 ) {
let applicationIdsFetching = tmp3 . applicationIdsFetching ;
tmp10 = ! applicationIdsFetching . has ( closure_12 ) ;
}
if ( tmp10 ) {
let applicationIdsFetched = tmp3 . applicationIdsFetched ;
tmp10 = ! applicationIdsFetched . has ( closure_12 ) ;
}
fetchingAllEntitlements = tmp10 ;
2026-07-20 16:05:17 +00:00
}
if ( ! fetchingAllEntitlements ) {
2026-07-29 08:29:29 +00:00
const applicationIdsFetching2 = tmp3 . applicationIdsFetching ;
fetchingAllEntitlements = applicationIdsFetching2 . has ( closure_12 ) ;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const tmp14 = stateFromStores ( stateFromStoresArray . useState ( calculateFractionalPremiumInfo ( { isFetching : fetchingAllEntitlements , entitlements : stateFromStoresArray , unactivatedFractionalPremiumUnits : stateFromStoresArray1 , currentUser : stateFromStores , premiumSubscription : stateFromStores2 , fetchedAllEntitlements : stateFromStores1 , excludeReverseTrialFromCountdown } ) ) , 2 ) ;
closure_8 = tmp14 [ 1 ] ;
importDefault ( tmp [ 12 ] ) ( ( ) = > {
let tmp3 = null != stateFromStores ;
if ( tmp3 ) {
tmp3 = ! stateFromStores2 . fetchingAllEntitlements ;
}
if ( tmp3 ) {
const fetchedAllEntitlements = stateFromStores2 . fetchedAllEntitlements ;
let tmp6 = ! fetchedAllEntitlements ;
if ( fetchedAllEntitlements ) {
tmp6 = forceFetch ;
}
tmp3 = tmp6 ;
}
if ( tmp3 ) {
2026-07-20 16:05:17 +00:00
let obj = forceFetch ( excludeReverseTrialFromCountdown [ 13 ] ) ;
2026-07-29 08:29:29 +00:00
obj = { entitlementType : null } ;
obj [ 0 ] = outer1_9 . FRACTIONAL_REDEMPTION ;
2026-07-20 16:05:17 +00:00
const userEntitlements = obj . fetchUserEntitlements ( obj ) ;
}
2026-07-29 08:29:29 +00:00
let tmp11 = null != stateFromStores ;
if ( tmp11 ) {
const applicationIdsFetching = stateFromStores2 . applicationIdsFetching ;
tmp11 = ! applicationIdsFetching . has ( outer1_12 ) ;
}
if ( tmp11 ) {
const applicationIdsFetched = stateFromStores2 . applicationIdsFetched ;
tmp11 = ! applicationIdsFetched . has ( outer1_12 ) ;
}
if ( tmp11 ) {
2026-07-23 10:11:24 +00:00
const userEntitlementsForApplication = forceFetch ( excludeReverseTrialFromCountdown [ 13 ] ) . fetchUserEntitlementsForApplication ( outer1_12 ) ;
2026-07-20 16:05:17 +00:00
const obj3 = forceFetch ( excludeReverseTrialFromCountdown [ 13 ] ) ;
}
} ) ;
const items5 = [ stateFromStores , stateFromStoresArray , stateFromStores2 , stateFromStoresArray1 , stateFromStores1 , excludeReverseTrialFromCountdown ] ;
2026-07-23 10:11:24 +00:00
const effect = stateFromStoresArray . useEffect ( ( ) = > {
let closure_0 = outer1_13 ( { entitlements : stateFromStoresArray , unactivatedFractionalPremiumUnits : stateFromStoresArray1 , currentUser : stateFromStores , premiumSubscription : stateFromStores2 , fetchedAllEntitlements : stateFromStores1 , excludeReverseTrialFromCountdown } ) ;
2026-07-20 16:05:17 +00:00
callback ( ( arg0 ) = > {
2026-07-29 08:29:29 +00:00
let tmp = callback ;
if ( obj . isEqual ( arg0 , callback ) ) {
tmp = arg0 ;
2026-07-20 16:05:17 +00:00
}
return tmp ;
} ) ;
} , items5 ) ;
2026-07-29 08:29:29 +00:00
return tmp14 [ 0 ] ;
2026-07-20 16:05:17 +00:00
} ;