decord/source/modules/billing/native/hooks/useMobilePurchaseSKU.android.tsx
2026-08-28 06:19:39 +00:00

448 lines
15 KiB
TypeScript

// Module ID: 10527
// Function ID: 10528
// Name: useMobilePurchaseSKU
// Dependencies: [5, 19, 7116, 1923, 676, 6050, 3, 10418, 10417, 5906, 698, 709, 7121, 4123, 1903, 10528, 514, 2]
// Exports: default
// Module 10527 (useMobilePurchaseSKU)
import timestampDefault from "timestamp" /* 3 */;
import closure_3 from "asyncGeneratorStep" /* 5 */;
import closure_4 from "noop" /* 19 */;
import { useNativeCheckoutStoreOrNull as closure_5 } from "context" /* 7116 */;
import closure_6 from "mergeGuildAvatar" /* 1923 */;
import { CurrencyCodes } from "ME" /* 676 */;
const require = arg1;
require("GPlayConnectionState").GPlayBillingResult;
let closure_9 = new timestampDefault("useMobilePurchaseSKU.android");
const tmp2 = new timestampDefault("useMobilePurchaseSKU.android");
let result = require("set").fileFinishedImporting("modules/billing/native/hooks/useMobilePurchaseSKU.android.tsx");
export default function useMobilePurchaseSKU(skuId) {
skuId = skuId.skuId;
let _require = skuId;
const platformSkuId = skuId.platformSkuId;
const analyticsLocations = skuId.analyticsLocations;
let analyticsLoadId = skuId.analyticsLoadId;
let callback = analyticsLoadId;
const analyticsData = skuId.analyticsData;
const onPurchaseComplete = skuId.onPurchaseComplete;
const onPurchaseError = skuId.onPurchaseError;
const freePurchaseCallback = skuId.freePurchaseCallback;
const onPurchasePending = skuId.onPurchasePending;
const giftParams = skuId.giftParams;
let flag = skuId.isFreeForStaffSelfPurchase;
if (flag === undefined) {
flag = true;
}
const orderId = skuId.orderId;
let handlePremiumPurchase;
let androidShopOrdersEnabled;
closure_14 = undefined;
closure_15 = undefined;
closure_16 = undefined;
closure_17 = undefined;
closure_18 = undefined;
let flag2;
callback = undefined;
let callback1;
let callback2;
let callback3;
const currentUser = onPurchaseError.getCurrentUser();
handlePremiumPurchase = _require(analyticsLocations[7]).useHandlePremiumPurchase();
let obj2 = _require(analyticsLocations[7]);
let tmp = analyticsLocations;
androidShopOrdersEnabled = _require(analyticsLocations[8]).useAndroidShopOrdersEnabled({ location: "useMobilePurchaseSKU" });
const tmp4 = onPurchaseComplete((setOrder) => setOrder.setOrder);
closure_14 = tmp4;
const tmp5 = onPurchaseComplete((setCheckoutSucceeded) => setCheckoutSucceeded.setCheckoutSucceeded);
closure_15 = tmp5;
const tmp6 = onPurchaseComplete((getPurchaseInFlight) => getPurchaseInFlight.getPurchaseInFlight);
closure_16 = tmp6;
const tmp7 = onPurchaseComplete((setPurchaseInFlight) => setPurchaseInFlight.setPurchaseInFlight);
closure_17 = tmp7;
let tmp8 = onPurchaseComplete((contextMetadata) => contextMetadata.contextMetadata.loadId);
const tmp9 = undefined !== currentUser && currentUser.isStaff();
closure_18 = tmp9;
flag2 = undefined;
let obj3 = _require(analyticsLocations[8]);
if (giftParams != null) {
flag2 = giftParams.isGift;
}
if (flag2 == null) {
flag2 = false;
}
if (null == analyticsLoadId) {
if (tmp8 == null) {
tmp8 = tmp10;
}
callback = tmp8;
analyticsLoadId = tmp8;
}
const items = [onPurchaseComplete, tmp5, tmp7];
callback = analyticsData.useCallback(() => {
platformSkuId(analyticsLocations[11]).unsubscribe("GPLAY_PURCHASE_VERIFIED", callback);
if (closure_17 != null) {
tmp2(false);
}
if (callback2 != null) {
callback2();
}
onPurchaseComplete();
}, items);
const items1 = [onPurchaseError, callback, tmp7];
callback1 = analyticsData.useCallback(() => {
platformSkuId(analyticsLocations[11]).unsubscribe("GPLAY_PURCHASE_VERIFIED", callback);
if (closure_17 != null) {
tmp2(false);
}
onPurchaseError();
}, items1);
const items2 = [onPurchaseError, tmp7];
callback2 = analyticsData.useCallback(() => {
if (closure_17 != null) {
tmp(false);
}
onPurchaseError();
}, items2);
_require = undefined;
_require = callback((arg0) => {
closure_0 = arg0;
c5 = 0;
c6 = 0;
c4 = 0;
return (function*(arg0) {
if (v0 === 2) {
v0 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp6 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
v0 = 2;
if (0 === c5) {
if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 === 2) {
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
closure_2 = tmp3;
closure_1 = tmp7;
let lib;
if (lib.billingResult === onPurchasePending.OK) {
if (closure_1_17 != null) {
closure_1_17(true);
}
} else {
platformSkuId(analyticsLocations[11]).unsubscribe("GPLAY_PURCHASE_VERIFIED", closure_1_20);
if (null != closure_1_11) {
if (closure_1_13) {
obj1 = { orderId: null, platformSkuId: null, skuId: null };
obj1[0] = closure_1_11;
obj1[1] = closure_1_1;
obj1[2] = lib;
giftParams.info("[handleGPlayUpdatePurchaseAction] User canceled purchase, canceling order signing", obj1);
c4 = 1;
c5 = 2;
v0 = 1;
const obj2 = { value: null, done: false };
obj2[0] = lib(analyticsLocations[12]).cancelOrderSigning(closure_1_11);
return obj2;
}
}
const obj11 = platformSkuId(analyticsLocations[11]);
}
closure_1_8();
v0 = 3;
}
} else if (1 === tmp7) {
c4 = 0;
closure_1 = closure_3;
obj1 = lib(analyticsLocations[13]);
const obj3 = { tags: null, extra: null };
obj3[0] = { source: "useMobilePurchaseSKU_cancelOrderSigning" };
const obj4 = { orderId: null };
obj4[0] = closure_1_11;
obj3[1] = obj4;
const result = obj1.captureBillingException(closure_1, obj3);
const obj5 = { error: null, orderId: null, skuId: null };
obj5[0] = closure_1;
obj5[1] = closure_1_11;
obj5[2] = lib;
giftParams.error("Failed to cancel order signing", obj5);
} else if (arg0 === 1) {
v0 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 0;
v0 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
lib = arg1;
if (closure_1_14 != null) {
tmp10(lib);
}
c4 = 0;
}
if (closure_1_17 != null) {
closure_1_17(false);
}
v0();
} catch (tmp46) {
closure_3 = tmp46;
if (tmp4 === c4) {
v0 = tmp2;
throw tmp46;
} else {
c5 = tmp;
}
}
}
})();
});
const items3 = [callback, onPurchaseError, onPurchasePending, tmp7, orderId, androidShopOrdersEnabled, tmp4, platformSkuId, skuId];
callback3 = analyticsData.useCallback(function() {
const self = this;
const apply = closure_0.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
}, items3);
const items4 = [callback3, callback, callback1];
const effect = analyticsData.useEffect(() => {
const subscription = platformSkuId(analyticsLocations[11]).subscribe("GPLAY_UPDATE_PURCHASE_STATE", callback3);
let obj = platformSkuId(analyticsLocations[11]);
const subscription1 = platformSkuId(analyticsLocations[11]).subscribe("GPLAY_PURCHASE_VERIFIED", callback);
let obj2 = platformSkuId(analyticsLocations[11]);
const subscription2 = platformSkuId(analyticsLocations[11]).subscribe("GPLAY_PURCHASE_VERIFICATION_FAILED", callback1);
return () => {
closure_1_1(closure_1_2[11]).unsubscribe("GPLAY_UPDATE_PURCHASE_STATE", closure_23);
const obj = closure_1_1(closure_1_2[11]);
closure_1_1(closure_1_2[11]).unsubscribe("GPLAY_PURCHASE_VERIFIED", closure_20);
const obj2 = closure_1_1(closure_1_2[11]);
closure_1_1(closure_1_2[11]).unsubscribe("GPLAY_PURCHASE_VERIFICATION_FAILED", closure_21);
};
}, items4);
const items5 = [skuId, platformSkuId, tmp9, flag2, handlePremiumPurchase, onPurchaseComplete, onPurchaseError, freePurchaseCallback, analyticsLoadId, analyticsLocations, analyticsData, giftParams, callback2, flag, tmp5, tmp6, tmp7, orderId, androidShopOrdersEnabled];
return analyticsData.useCallback(callback(function*() {
if (v02 === 2) {
v02 = 3;
HermesBuiltin.throwTypeError();
} else if (tmp8 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
v02 = 2;
if (0 === v0) {
if (arg0 === 1) {
v02 = 3;
throw arg1;
} else if (arg0 === 2) {
v02 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
closure_2 = tmp4;
closure_1 = tmp9;
let tmp52;
if (closure_1_16 != null) {
tmp52 = closure_1_16();
}
if (true === tmp52) {
const _Error2 = Error;
error = new Error("Purchase already in progress");
throw error;
} else {
let tmp = closure_1_2;
tmp = closure_1_1;
if (obj17.isNullOrEmpty(closure_1_1)) {
const _Error = Error;
const error1 = new Error("Missing google play sku ID");
throw error1;
} else {
c4 = 1;
if (closure_1_17 != null) {
closure_1_17(true);
}
if (closure_1_18) {
if (closure_1_10) {
if (!closure_1_19) {
c4 = 3;
callback = closure_1_7;
if (closure_1_7 == null) {
callback = closure_1_0(closure_1_2[15]).purchaseSKU;
}
obj1 = { expectedAmount: 0, expectedCurrency: null, loadId: null };
obj1[1] = closure_1_7.USD;
let obj8 = closure_1_0(closure_1_2[16]);
obj1[2] = obj8.v4();
v0 = 4;
v02 = 1;
let obj2 = { value: null, done: false };
obj2[0] = callback("collectibles", closure_1_0, obj1);
return obj2;
}
}
}
if (null != closure_1_11) {
if (closure_1_13) {
c4 = 4;
v0 = 6;
v02 = 1;
const obj3 = { value: null, done: false };
obj3[0] = closure_1_0(closure_1_2[12]).markOrderAsSigningInProgress(closure_1_11);
return obj3;
}
}
}
obj17 = closure_1_0(closure_1_2[14]);
}
}
} else if (1 === tmp9) {
c4 = 0;
closure_2 = closure_3;
if (callback3 != null) {
callback3(false);
}
throw closure_2;
} else if (2 === tmp9) {
c4 = 1;
if (closure_1_17 != null) {
closure_1_17(false);
}
throw closure_3;
} else if (3 === tmp9) {
c4 = 2;
callback = closure_3;
v02();
throw callback;
} else {
if (4 === tmp9) {
if (arg0 === 1) {
v02 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 1;
if (callback3 != null) {
callback3(false);
}
c4 = 0;
v02 = 3;
const obj4 = { value: null, done: true };
obj4[0] = arg1;
return obj4;
} else {
if (callback2 != null) {
callback2();
}
v0();
c4 = 1;
if (callback3 != null) {
callback3(false);
}
}
} else if (5 === tmp9) {
c4 = 1;
closure_1 = closure_3;
obj2 = closure_1_0(closure_1_2[13]);
const obj5 = { tags: null, extra: null };
obj5[0] = { source: "useMobilePurchaseSKU_markSigning" };
const obj6 = { orderId: null };
obj6[0] = closure_11;
obj5[1] = obj6;
const result = obj2.captureBillingException(closure_1, obj5);
const obj7 = { error: null, skuId: null, orderId: null };
obj7[0] = closure_1;
obj7[1] = callback;
obj7[2] = closure_11;
closure_1_9.error("Failed to mark order signing-in-progress", obj7);
throw closure_1;
} else if (6 === tmp9) {
if (arg0 === 1) {
v02 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 0;
v02 = 3;
obj8 = { value: null, done: true };
obj8[0] = arg1;
return obj8;
} else {
c4 = 1;
}
} else if (arg0 === 1) {
v02 = 3;
throw arg1;
} else if (arg0 === 2) {
c4 = 0;
v02 = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
}
c4 = 0;
v02 = 3;
return { value: "HermesInternal", done: null };
}
const obj9 = { productId: null, skuId: null, isOneTimePurchase: true, analyticsLoadId: null, analyticsLocations: null, analyticsData: null, isGift: null, giftInfoOptions: null, onPurchaseError: null };
obj9[0] = closure_1;
obj9[1] = callback;
obj9[3] = closure_3;
obj9[4] = closure_2;
obj9[5] = c4;
obj9[6] = closure_19;
let options;
if (options != null) {
options = options.options;
}
obj9[7] = options;
obj9[8] = closure_22;
v0 = 7;
v02 = 1;
const obj10 = { value: null, done: false };
obj10[0] = closure_12(obj9);
return obj10;
} catch (tmp89) {
closure_3 = tmp89;
if (tmp5 === c4) {
v02 = tmp3;
throw tmp89;
} else if (tmp2 === tmp91) {
v0 = tmp2;
} else if (tmp === tmp91) {
v0 = tmp;
} else if (tmp3 === tmp91) {
v0 = tmp3;
} else {
v0 = tmp6;
}
}
}
}), items5);
};