195 lines
4.9 KiB
TypeScript
195 lines
4.9 KiB
TypeScript
// Metro module 5667 (f5668).
|
|
import LocaleStore from "../user_settings/LocaleStore";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import { isNotNullish } from "../../utils/GlobalUtils";
|
|
import Dispatcher from "../../Dispatcher";
|
|
function $mk76656($env) {
|
|
return (a0) => {
|
|
const r0 = {
|
|
type: "sku",
|
|
skuId: a0
|
|
};
|
|
return [r0.type === "application" ? `application:${r0.applicationId}` : `skus:${r0.skuId}`, $env[0]];
|
|
};
|
|
}
|
|
let c3505_3, c3505_4, c3505_5, c3505_6;
|
|
const resetStoreState = function resetStoreState() {
|
|
c3505_3 = {};
|
|
c3505_4 = {};
|
|
c3505_5 = {};
|
|
c3505_6 = {};
|
|
};
|
|
c3505_3 = {};
|
|
c3505_4 = {};
|
|
c3505_5 = {};
|
|
c3505_6 = {};
|
|
class SKUPricesStore extends Module589.Store {
|
|
static displayName = "SKUPricesStore";
|
|
initialize() {
|
|
this.waitFor(LocaleStore);
|
|
this.syncWith([LocaleStore], resetStoreState);
|
|
}
|
|
getPricesForSkuId(a0) {
|
|
if (a0 != null) {
|
|
const pricingResultId = c3505_6[a0]?.pricingResultId;
|
|
if (pricingResultId != null) {
|
|
return c3505_4[pricingResultId];
|
|
}
|
|
}
|
|
}
|
|
getFetchStateForSkuId(a0) {
|
|
if (a0 != null) {
|
|
const r3 = {
|
|
type: "sku",
|
|
skuId: a0
|
|
};
|
|
return c3505_3[r3.type === "application" ? `application:${r3.applicationId}` : `skus:${r3.skuId}`];
|
|
}
|
|
}
|
|
getFetchStateForApplicationId(a0) {
|
|
if (a0 != null) {
|
|
const r3 = {
|
|
type: "application",
|
|
applicationId: a0
|
|
};
|
|
return c3505_3[r3.type === "application" ? `application:${r3.applicationId}` : `skus:${r3.skuId}`];
|
|
}
|
|
}
|
|
getRewardsForSkuId(a0) {
|
|
if (a0 != null) {
|
|
const r5 = c3505_6[a0];
|
|
if (r5 != null) {
|
|
return r5.rewardResultIds.map((rewardResultId) => c3505_5[rewardResultId]).filter(isNotNullish);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const sKUPricesStore = new SKUPricesStore(Dispatcher, {
|
|
LOGOUT: resetStoreState,
|
|
SKUS_PRICING_FETCH_START: function handleFetchStart({ priceId }) {
|
|
let r14;
|
|
let env14994;
|
|
const r5 = {
|
|
type: "loading"
|
|
};
|
|
const r3 = env14994 = {};
|
|
env14994[0] = r5;
|
|
if (priceId.type === "application") {
|
|
const r22 = {
|
|
...c3505_3
|
|
};
|
|
const r27 = {
|
|
type: "application",
|
|
applicationId: priceId.applicationId
|
|
};
|
|
r22[r27.type === "application" ? `application:${r27.applicationId}` : `skus:${r27.skuId}`] = r5;
|
|
r14 = r22;
|
|
} else {
|
|
r14 = {
|
|
...c3505_3,
|
|
...Object.fromEntries(priceId.skuIds.map($mk76656(r3)))
|
|
};
|
|
}
|
|
c3505_3 = r14;
|
|
},
|
|
SKUS_PRICING_FETCH_SUCCESS: function handleFetchSuccess({ priceId, data }) {
|
|
let r19, r51;
|
|
let env14995;
|
|
const fetchedAt = Date.now();
|
|
const r10 = {
|
|
type: "success",
|
|
fetchedAt
|
|
};
|
|
const r6 = env14995 = {};
|
|
env14995[0] = r10;
|
|
if (priceId.type === "application") {
|
|
const r26 = {
|
|
...c3505_3
|
|
};
|
|
const r31 = {
|
|
type: "application",
|
|
applicationId: priceId.applicationId
|
|
};
|
|
r26[r31.type === "application" ? `application:${r31.applicationId}` : `skus:${r31.skuId}`] = r10;
|
|
r19 = r26;
|
|
} else {
|
|
r19 = {
|
|
...c3505_3,
|
|
...Object.fromEntries(priceId.skuIds.map($mk76656(r6)))
|
|
};
|
|
}
|
|
c3505_3 = r19;
|
|
if (priceId.type === "application") {
|
|
let env14996;
|
|
const r47 = {
|
|
type: "skus",
|
|
skuIds: Object.keys(data.skuPriceMap)
|
|
};
|
|
const r48 = {
|
|
type: "success",
|
|
fetchedAt
|
|
};
|
|
const r49 = env14996 = {};
|
|
env14996[0] = r48;
|
|
if (r47.type === "application") {
|
|
const r64 = {
|
|
...c3505_3
|
|
};
|
|
const r69 = {
|
|
type: "application",
|
|
applicationId: r47.applicationId
|
|
};
|
|
r64[r69.type === "application" ? `application:${r69.applicationId}` : `skus:${r69.skuId}`] = r48;
|
|
r51 = r64;
|
|
} else {
|
|
r51 = {
|
|
...c3505_3,
|
|
...Object.fromEntries(r47.skuIds.map($mk76656(r49)))
|
|
};
|
|
}
|
|
c3505_3 = r51;
|
|
}
|
|
c3505_4 = {
|
|
...c3505_4,
|
|
...data.pricingResultIdMap
|
|
};
|
|
c3505_6 = {
|
|
...c3505_6,
|
|
...data.skuPriceMap
|
|
};
|
|
c3505_5 = {
|
|
...c3505_5,
|
|
...data.rewardResultIdMap
|
|
};
|
|
},
|
|
SKUS_PRICING_FETCH_FAIL: function handleFetchFail({ priceId }) {
|
|
let r18;
|
|
let env14997;
|
|
const r5 = {
|
|
type: "error",
|
|
fetchedAt: Date.now()
|
|
};
|
|
const r16 = env14997 = {};
|
|
env14997[0] = r5;
|
|
if (priceId.type === "application") {
|
|
const r25 = {
|
|
...c3505_3
|
|
};
|
|
const r30 = {
|
|
type: "application",
|
|
applicationId: priceId.applicationId
|
|
};
|
|
r25[r30.type === "application" ? `application:${r30.applicationId}` : `skus:${r30.skuId}`] = r5;
|
|
r18 = r25;
|
|
} else {
|
|
r18 = {
|
|
...c3505_3,
|
|
...Object.fromEntries(priceId.skuIds.map($mk76656(r16)))
|
|
};
|
|
}
|
|
c3505_3 = r18;
|
|
},
|
|
STOREFRONT_PROMOTION_ID_OVERRIDE_SET: resetStoreState
|
|
});
|
|
export default sKUPricesStore;
|