decord/source/stores/billing/SubscriptionStore.tsx

416 lines
12 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 4048
// Function ID: 4049
2026-07-29 08:29:29 +00:00
// Name: reset
2026-08-24 06:08:38 +00:00
// Dependencies: [1923, 4043, 4049, 1218, 676, 589, 709, 2]
2026-07-29 08:29:29 +00:00
// Exports: getSubscriptionOfType
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 4048 (reset)
import initializeDefault from "initialize" /* 589 */;
import dispatcherDefault from "dispatcher" /* 709 */;
import closure_0 from "setPremiumTypeActual" /* 1923 */;
import { isNoneSubscription } from "createFromServer" /* 4043 */;
import { SubscriptionRecord } from "createSubscriptionItemFromServer" /* 4049 */;
import closure_3 from "fetchFingerprint" /* 1218 */;
import ME from "ME" /* 676 */;
2026-07-23 10:11:24 +00:00
2026-07-20 16:05:17 +00:00
function reset() {
2026-08-24 06:08:38 +00:00
c6 = null;
c7 = null;
c8 = null;
c9 = null;
c10 = null;
c11 = false;
c12 = null;
c13 = false;
c14 = false;
c16 = false;
c17 = null;
2026-07-20 16:05:17 +00:00
}
2026-08-05 07:35:12 +00:00
({ SubscriptionStatusTypes: c4, SubscriptionTypes: c5 } = ME);
2026-07-29 08:29:29 +00:00
let c6 = null;
let c7 = null;
let c8 = null;
let c9 = null;
2026-08-05 07:35:12 +00:00
let c10 = null;
let c11 = false;
let c12 = null;
2026-07-29 08:29:29 +00:00
let c13 = false;
2026-08-05 07:35:12 +00:00
let c14 = false;
let c15 = null;
let c16 = false;
let c17 = null;
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class SubscriptionStore extends Store {
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const prototype = SubscriptionStore.prototype;
prototype["initialize"] = function initialize() {
2026-08-24 06:08:38 +00:00
this.waitFor(closure_3, closure_0);
2026-07-29 08:29:29 +00:00
};
prototype["hasFetchedSubscriptions"] = function hasFetchedSubscriptions() {
2026-08-05 07:35:12 +00:00
return null != c6;
2026-07-29 08:29:29 +00:00
};
prototype["hasFetchedMostRecentPremiumTypeSubscription"] = function hasFetchedMostRecentPremiumTypeSubscription() {
2026-08-05 07:35:12 +00:00
return c11;
2026-07-29 08:29:29 +00:00
};
prototype["hasFetchedPreviousPremiumTypeSubscription"] = function hasFetchedPreviousPremiumTypeSubscription() {
2026-08-05 07:35:12 +00:00
return c13;
2026-07-29 08:29:29 +00:00
};
prototype["getPremiumSubscription"] = function getPremiumSubscription(arg0) {
let flag = arg0;
if (arg0 === undefined) {
2026-07-20 16:05:17 +00:00
flag = true;
}
2026-08-05 07:35:12 +00:00
const PREMIUM = constants2.PREMIUM;
2026-07-29 08:29:29 +00:00
if (flag === undefined) {
flag = true;
}
2026-08-05 07:35:12 +00:00
if (PREMIUM !== constants2.PREMIUM) {
const tmp5 = flag ? c7 : c6;
let tmp4 = null;
if (null != tmp5) {
2026-07-29 08:29:29 +00:00
tmp4 = null;
2026-08-05 07:35:12 +00:00
const keys = Object.keys();
if (keys !== undefined) {
2026-07-29 08:29:29 +00:00
tmp4 = null;
2026-08-05 07:35:12 +00:00
while (keys[tmp] !== undefined) {
let tmp13 = tmp9;
let tmp14 = tmp5[tmp9];
let tmp15 = store2;
tmp4 = null;
if (tmp14.userId !== store2.getId()) {
break;
2026-07-29 08:29:29 +00:00
} else {
2026-08-05 07:35:12 +00:00
if (tmp14.type !== PREMIUM) {
continue;
} else {
let tmp10 = isNoneSubscription;
let tmp11 = isNoneSubscription(tmp14.planId);
let tmp12 = !tmp11;
tmp4 = tmp14;
if (!tmp11) {
break;
}
2026-07-29 08:29:29 +00:00
}
2026-08-05 07:35:12 +00:00
continue;
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
}
}
}
2026-08-05 07:35:12 +00:00
} else {
tmp4 = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp4;
};
prototype["getPremiumTypeSubscription"] = function getPremiumTypeSubscription(arg0) {
let flag = arg0;
if (arg0 === undefined) {
flag = true;
2026-07-20 16:05:17 +00:00
}
2026-08-05 07:35:12 +00:00
const PREMIUM = constants2.PREMIUM;
2026-07-29 08:29:29 +00:00
if (flag === undefined) {
flag = true;
}
2026-08-05 07:35:12 +00:00
if (PREMIUM !== constants2.PREMIUM) {
const tmp5 = flag ? c7 : c6;
let tmp4 = null;
if (null != tmp5) {
2026-07-29 08:29:29 +00:00
tmp4 = null;
2026-08-05 07:35:12 +00:00
const keys = Object.keys();
if (keys !== undefined) {
2026-07-29 08:29:29 +00:00
tmp4 = null;
2026-08-05 07:35:12 +00:00
while (keys[tmp] !== undefined) {
let tmp10 = tmp9;
let tmp11 = tmp5[tmp9];
let tmp12 = store2;
tmp4 = null;
if (tmp11.userId !== store2.getId()) {
2026-07-29 08:29:29 +00:00
break;
2026-08-05 07:35:12 +00:00
} else {
tmp4 = tmp11;
if (tmp11.type === PREMIUM) {
break;
}
2026-07-29 08:29:29 +00:00
}
}
2026-07-20 16:05:17 +00:00
}
}
2026-08-05 07:35:12 +00:00
} else {
tmp4 = null;
2026-07-29 08:29:29 +00:00
}
return tmp4;
};
prototype["getSubscriptions"] = function getSubscriptions(arg0) {
let flag = arg0;
if (arg0 === undefined) {
flag = true;
}
2026-08-05 07:35:12 +00:00
return flag ? c7 : c6;
2026-07-29 08:29:29 +00:00
};
prototype["getSubscriptionById"] = function getSubscriptionById(subscription_id) {
let tmp2;
2026-08-05 07:35:12 +00:00
if (c6 != null) {
2026-07-29 08:29:29 +00:00
tmp2 = tmp[subscription_id];
}
return tmp2;
};
prototype["getActiveGuildSubscriptions"] = function getActiveGuildSubscriptions() {
2026-08-05 07:35:12 +00:00
return c9;
2026-07-29 08:29:29 +00:00
};
prototype["getActiveApplicationSubscriptions"] = function getActiveApplicationSubscriptions() {
2026-08-05 07:35:12 +00:00
return c10;
2026-07-29 08:29:29 +00:00
};
prototype["getSubscriptionForPlanIds"] = function getSubscriptionForPlanIds(items) {
let flag = arg1;
if (arg1 === undefined) {
flag = true;
}
let set;
set = new Set(items);
2026-08-05 07:35:12 +00:00
const tmp2 = flag ? c7 : c6;
2026-07-29 08:29:29 +00:00
let tmp3 = null;
if (null != tmp2) {
const _Object = Object;
const values = Object.values(tmp2);
let found = values.find((items) => {
items = items.items;
return items.some((planId) => set.has(planId.planId));
});
if (found == null) {
found = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp3 = found;
}
return tmp3;
};
prototype["getMostRecentPremiumTypeSubscription"] = function getMostRecentPremiumTypeSubscription() {
2026-08-05 07:35:12 +00:00
return c8;
2026-07-29 08:29:29 +00:00
};
prototype["getPreviousPremiumTypeSubscription"] = function getPreviousPremiumTypeSubscription() {
2026-08-05 07:35:12 +00:00
return c12;
2026-07-29 08:29:29 +00:00
};
prototype["getIsSubscriptionEligibleForReward"] = function getIsSubscriptionEligibleForReward() {
2026-08-05 07:35:12 +00:00
return c15;
2026-07-29 08:29:29 +00:00
};
prototype["getIsFetchingSubscriptionRewardEligibility"] = function getIsFetchingSubscriptionRewardEligibility() {
2026-08-05 07:35:12 +00:00
return c14;
2026-07-29 08:29:29 +00:00
};
prototype["getIsFetchingMostRecentSubscription"] = function getIsFetchingMostRecentSubscription() {
2026-08-05 07:35:12 +00:00
return c16;
2026-07-29 08:29:29 +00:00
};
prototype["getLastLazyPerkSync"] = function getLastLazyPerkSync() {
2026-08-05 07:35:12 +00:00
return c17;
2026-07-29 08:29:29 +00:00
};
prototype["getPremiumGroupSubscription"] = function getPremiumGroupSubscription() {
2026-08-05 07:35:12 +00:00
const PREMIUM = constants2.PREMIUM;
if (PREMIUM !== constants2.PREMIUM) {
let tmp3 = null;
if (null != c7) {
tmp3 = null;
const keys = Object.keys();
if (keys !== undefined) {
tmp3 = null;
while (keys[tmp] !== undefined) {
let tmp10 = tmp8;
let tmp11 = tmp4[tmp8];
let tmp12 = store2;
tmp3 = null;
if (tmp11.userId !== store2.getId()) {
break;
2026-07-29 08:29:29 +00:00
} else {
2026-08-05 07:35:12 +00:00
if (tmp11.type !== PREMIUM) {
continue;
} else {
let tmp9 = tmp11.hasAnyPremiumGroup && tmp11.statusAllowsPerks;
tmp3 = tmp11;
if (tmp9) {
break;
}
2026-07-29 08:29:29 +00:00
}
2026-08-05 07:35:12 +00:00
continue;
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
}
}
}
2026-08-05 07:35:12 +00:00
} else {
tmp3 = null;
2026-07-29 08:29:29 +00:00
}
2026-08-05 07:35:12 +00:00
return tmp3;
2026-07-29 08:29:29 +00:00
};
SubscriptionStore.displayName = "SubscriptionStore";
2026-08-24 06:08:38 +00:00
const subscriptionStore = new SubscriptionStore(dispatcherDefault, {
2026-07-20 16:05:17 +00:00
BILLING_SUBSCRIPTION_FETCH_SUCCESS: function handleSubscriptionsFetch(subscriptions) {
subscriptions = subscriptions.subscriptions;
2026-07-29 08:29:29 +00:00
let id;
2026-07-20 16:05:17 +00:00
let obj = {};
obj = {};
const items = [];
const items1 = [];
2026-08-05 07:35:12 +00:00
id = items1.getId();
2026-07-20 16:05:17 +00:00
const item = subscriptions.forEach((user_id) => {
2026-07-29 08:29:29 +00:00
if (user_id.user_id === constants) {
2026-08-05 07:35:12 +00:00
const fromServer = items.createFromServer(user_id);
2026-07-20 16:05:17 +00:00
obj[fromServer.id] = fromServer;
2026-08-05 07:35:12 +00:00
if (fromServer.status !== constants.UNPAID) {
2026-07-20 16:05:17 +00:00
obj[fromServer.id] = fromServer;
2026-08-24 06:08:38 +00:00
let tmp3 = fromServer.type === closure_1_5.GUILD;
2026-07-20 16:05:17 +00:00
if (tmp3) {
2026-07-29 08:29:29 +00:00
tmp3 = fromServer.status !== tmp12.ENDED;
2026-07-20 16:05:17 +00:00
}
if (tmp3) {
items.push(fromServer);
}
2026-07-29 08:29:29 +00:00
if (tmp6) {
2026-07-20 16:05:17 +00:00
items1.push(fromServer);
}
2026-08-24 06:08:38 +00:00
const tmp2 = closure_1_5;
tmp6 = fromServer.type === closure_1_5.APPLICATION && fromServer.status !== tmp12.ENDED;
2026-07-20 16:05:17 +00:00
}
}
});
const lastLazyPerkSync = subscriptions.lastLazyPerkSync;
},
BILLING_SUBSCRIPTION_UPDATE_SUCCESS: function handleSubscriptionUpdate(subscription) {
subscription = subscription.subscription;
2026-08-05 07:35:12 +00:00
if (subscription.user_id === store2.getId()) {
2026-07-20 16:05:17 +00:00
const fromServer = SubscriptionRecord.createFromServer(subscription);
let obj = {};
2026-07-23 10:11:24 +00:00
const merged = Object.assign(obj);
2026-07-20 16:05:17 +00:00
obj[fromServer.id] = fromServer;
2026-07-29 08:29:29 +00:00
if (fromServer.status !== constants.UNPAID) {
2026-07-20 16:05:17 +00:00
obj = {};
2026-07-23 10:11:24 +00:00
const merged1 = Object.assign(obj);
2026-07-20 16:05:17 +00:00
obj[fromServer.id] = fromServer;
}
2026-08-24 06:08:38 +00:00
let tmp6 = null != items1;
2026-07-20 16:05:17 +00:00
if (tmp6) {
tmp6 = fromServer.type === constants2.GUILD;
}
2026-07-29 08:29:29 +00:00
if (!tmp6) {
2026-08-24 06:08:38 +00:00
let tmp19 = null != _null;
2026-07-29 08:29:29 +00:00
if (tmp19) {
tmp19 = fromServer.type === constants2.APPLICATION;
}
if (tmp19) {
2026-08-24 06:08:38 +00:00
const findIndexResult = _null.findIndex((id) => id.id === fromServer.id);
2026-07-29 08:29:29 +00:00
if (-1 === findIndexResult) {
let items = [fromServer];
HermesBuiltin.arraySpread(tmp21, 1);
let tmp27 = items;
} else {
items = [];
HermesBuiltin.arraySpread(tmp21, 0);
if (fromServer.status === tmp36.UNPAID) {
items.splice(findIndexResult, 1);
tmp27 = items;
}
items[findIndexResult] = fromServer;
tmp27 = items;
}
2026-08-24 06:08:38 +00:00
items1 = tmp27;
2026-07-29 08:29:29 +00:00
}
} else {
2026-08-24 06:08:38 +00:00
const findIndexResult1 = items1.findIndex((id) => id.id === fromServer.id);
2026-07-29 08:29:29 +00:00
if (-1 === findIndexResult1) {
2026-08-24 06:08:38 +00:00
items1 = [fromServer];
2026-07-29 08:29:29 +00:00
HermesBuiltin.arraySpread(tmp8, 1);
let tmp14 = items1;
} else {
items1 = [];
HermesBuiltin.arraySpread(tmp8, 0);
if (fromServer.status === tmp36.UNPAID) {
items1.splice(findIndexResult1, 1);
tmp14 = items1;
}
items1[findIndexResult1] = fromServer;
tmp14 = items1;
}
2026-08-24 06:08:38 +00:00
items1 = tmp14;
2026-07-20 16:05:17 +00:00
}
}
},
BILLING_MOST_RECENT_SUBSCRIPTION_FETCH_START: function handleMostRecentSubscriptionFetchStart() {
2026-08-24 06:08:38 +00:00
c16 = true;
2026-07-20 16:05:17 +00:00
},
BILLING_MOST_RECENT_SUBSCRIPTION_FETCH_SUCCESS: function handleMostRecentSubscriptionFetch(subscription) {
subscription = subscription.subscription;
2026-08-24 06:08:38 +00:00
c11 = true;
c16 = false;
2026-07-20 16:05:17 +00:00
if (null != subscription) {
2026-08-05 07:35:12 +00:00
if (subscription.user_id !== store2.getId()) {
c11 = false;
2026-07-20 16:05:17 +00:00
} else {
2026-08-24 06:08:38 +00:00
closure_8 = SubscriptionRecord.createFromServer(subscription);
2026-07-20 16:05:17 +00:00
}
}
},
BILLING_MOST_RECENT_SUBSCRIPTION_FETCH_FAIL: function handleMostRecentSubscriptionFetchFail() {
2026-08-24 06:08:38 +00:00
c16 = false;
2026-07-20 16:05:17 +00:00
},
BILLING_PREVIOUS_PREMIUM_SUBSCRIPTION_FETCH_SUCCESS: function handlePreviousSubscriptionFetch(subscription) {
subscription = subscription.subscription;
2026-08-24 06:08:38 +00:00
c13 = true;
2026-07-20 16:05:17 +00:00
if (null != subscription) {
2026-08-05 07:35:12 +00:00
if (subscription.user_id !== store2.getId()) {
c13 = false;
2026-07-20 16:05:17 +00:00
} else {
2026-08-24 06:08:38 +00:00
closure_12 = SubscriptionRecord.createFromServer(subscription);
2026-07-20 16:05:17 +00:00
}
}
},
BILLING_SUBSCRIPTION_RESET: reset,
BILLING_SUBSCRIPTION_REWARD_ELIGIBILITY_FETCH_START: function handleSubscriptionRewardEligibilityFetchStart() {
2026-08-24 06:08:38 +00:00
c14 = true;
2026-07-20 16:05:17 +00:00
},
BILLING_SUBSCRIPTION_REWARD_ELIGIBILITY_FETCH_SUCCESS: function handleSubscriptionRewardEligibilityFetch(eligible) {
eligible = eligible.eligible;
2026-08-24 06:08:38 +00:00
c14 = false;
2026-07-20 16:05:17 +00:00
},
BILLING_SUBSCRIPTION_REWARD_ELIGIBILITY_FETCH_FAILURE: function handleSubscriptionRewardEligibilityFetchFailed(arg0) {
if (arg0 == null) {
2026-07-29 08:29:29 +00:00
HermesBuiltin.throwTypeError();
2026-07-20 16:05:17 +00:00
} else {
2026-08-24 06:08:38 +00:00
c15 = false;
c14 = false;
2026-07-20 16:05:17 +00:00
}
},
2026-08-05 07:35:12 +00:00
SET_PREMIUM_TYPE_OVERRIDE: function handlePremiumTypeOverride() {
return true;
},
2026-07-20 16:05:17 +00:00
LOGOUT: reset
});
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("stores/billing/SubscriptionStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default subscriptionStore;
export const getSubscriptionOfType = function getSubscriptionOfType(arg0, arg1) {
let flag = arg2;
if (arg2 === undefined) {
flag = true;
}
2026-08-05 07:35:12 +00:00
if (arg0 === constants2.PREMIUM) {
if (null === store.getPremiumTypeOverride()) {
return null;
}
}
const tmp3 = flag ? c7 : c6;
if (null == tmp3) {
2026-07-29 08:29:29 +00:00
return null;
} else {
2026-08-05 07:35:12 +00:00
for (const key10014 in tmp3) {
let tmp5 = key10014;
let tmp6 = tmp3[key10014];
let tmp7 = store2;
if (tmp6.userId !== store2.getId()) {
2026-07-29 08:29:29 +00:00
return null;
} else {
2026-08-05 07:35:12 +00:00
if (tmp6.type !== arg0) {
2026-07-29 08:29:29 +00:00
continue;
} else {
2026-08-05 07:35:12 +00:00
return tmp6;
2026-07-29 08:29:29 +00:00
}
continue;
}
}
return null;
}
};