// Module ID: 10182 // Function ID: 10183 // Name: useSyncGiftOptionsToOrder // Dependencies: [32, 19, 7144, 3, 558, 576, 10057, 7149, 4784, 2] // Module 10182 (useSyncGiftOptionsToOrder) import LoggerDefault from "Logger" /* 3 */; import BillingUtils from "BillingUtils" /* 4784 */; import NativeCheckoutStore from "NativeCheckoutStore" /* 7144 */; import useGiftOptionsSyncDebounceDefault from "useGiftOptionsSyncDebounce" /* 10057 */; import _slicedToArray from "_slicedToArray" /* 32 */; import react_mod from "react" /* 19 */; import ReactCompilerGating from "ReactCompilerGating" /* 558 */; import size from "module_2" /* 2 */; const require = globalThis.__r; let _require, cleanupPromise, clearTimeoutResult, dependencyMap, flag, flag2, flag3, importDefault, num, num2, obj1, obj4, ref, ref4, ref5, ref6, tmp11, tmp14, tmp17, tmp18, tmp20, tmp21, tmp22, tmp24, tmp25, tmp6; let react = react_mod; let ref2 = NativeCheckoutStore.useNativeCheckoutStoreOrNull; const tmp2 = new LoggerDefault("useSyncGiftOptionsToOrder"); let ref3 = tmp2; let tmp3 = ReactCompilerGating.isReactCompilerEnabled() ? (function useSyncGiftOptionsToOrder(arg0, current) { let closure_0; let closure_10; let first; let ref7; let ref8; let tmp10; let tmp4; let tmp5; let tmp9; _require = arg0; importDefault = current; let tmp = dependencyMap; let obj = require("react"); const cResult = obj.c(22); let obj2 = react; dependencyMap = react.useRef(null); ref = react.useRef(null); react = react.useRef(false); ref2 = react.useRef(undefined); ref3 = react.useRef(null); ref4 = react.useRef(0); ref5 = react.useRef(null); ref6 = react.useRef(null); const tmp3 = ref(react.useState(0), 2); [tmp4, tmp5] = tmp3; if (cResult[0] === Symbol.for("react.memo_cache_sentinel")) { const fn = function o(setOrderRevision) { return setOrderRevision.setOrderRevision; }; cResult[0] = fn; first = fn; } else { first = cResult[0]; } let tmp7 = ref2(first); let closure_11 = tmp7; let tmp8 = useGiftOptionsSyncDebounceDefault(tmp5); const waitForPause = tmp8.waitForPause; const flush = tmp8.flush; const waitForSync = tmp8.waitForSync; const resolveSyncs = tmp8.resolveSyncs; if (cResult[1] === Symbol.for("react.memo_cache_sentinel")) { const fn2 = function k() { return () => { if (null != ref.current) { const _clearTimeout = clearTimeout; clearTimeout(tmp.current); } }; }; const items = []; cResult[1] = fn2; cResult[2] = items; tmp10 = items; tmp9 = fn2; } else { tmp9 = cResult[1]; tmp10 = cResult[2]; } const effect = obj2.useEffect(tmp9, tmp10); if (cResult[3] === current) { if (cResult[4] === arg0) { if (cResult[5] === resolveSyncs) { if (cResult[6] === tmp7) { let tmp12; if (cResult[7] === waitForPause) { tmp12 = cResult[8]; } if (cResult[9] === current) { if (cResult[10] === arg0) { if (cResult[11] === resolveSyncs) { if (cResult[12] === tmp7) { if (cResult[13] === tmp4) { let tmp13; if (cResult[14] === waitForPause) { tmp13 = cResult[15]; } const effect1 = obj2.useEffect(tmp12, tmp13); if (cResult[16] === flush) { if (cResult[17] === arg0) { let tmp15; let tmp16; if (cResult[18] === waitForSync) { tmp15 = cResult[19]; } if (cResult[20] !== tmp15) { let obj3 = { awaitSync: tmp15 }; class G { constructor() { if (null != closure_0) { if (ref.current !== ref2.current) { if (ref6.current >= 3) { tmp3.current = 0; } current = ref3.current; const tmp5 = flush(tmp2.current); const tmp7 = waitForSync(); if (!current) { current = null != ref8.current; } if (!current) { tmp5((arg0) => arg0 + 1); } return tmp7; } } return Promise.resolve(true); } } cResult[21] = obj3; tmp16 = obj3; } else { tmp16 = cResult[21]; } return tmp16; } } class G { constructor() { if (null != closure_0) { if (ref.current !== ref2.current) { if (ref6.current >= 3) { tmp3.current = 0; } current = ref3.current; const tmp5 = flush(tmp2.current); const tmp7 = waitForSync(); if (!current) { current = null != ref8.current; } if (!current) { tmp5((arg0) => arg0 + 1); } return tmp7; } } return Promise.resolve(true); } } cResult[16] = flush; cResult[17] = arg0; cResult[18] = waitForSync; cResult[19] = G; tmp15 = G; } } } } } const items1 = [, current, tmp4, resolveSyncs, tmp7, waitForPause]; cResult[9] = current; cResult[10] = arg0; cResult[11] = resolveSyncs; cResult[12] = tmp7; cResult[13] = tmp4; cResult[14] = waitForPause; cResult[15] = items1; tmp13 = items1; } } } } class E { constructor() { tmp = id; if (null != id) { id = tmp.id; tmp4 = closure_3; tmp5 = closure_1; closure_3.current = closure_1; if (closure_6.current !== id) { closure_6.current = id; tmp9 = closure_5; closure_5.current = tmp.revision; tmp10 = closure_2; closure_2.current = null; tmp11 = closure_8; closure_8.current = null; tmp12 = closure_7; num = 0; closure_7.current = 0; tmp8 = closure_5; } else { tmp6 = closure_5; tmp7 = null == closure_5.current || tmp.revision > tmp6.current; tmp8 = tmp6; if (tmp7) { tmp6.current = tmp.revision; tmp8 = tmp6; } } tmp13 = closure_8; if (closure_8.current !== tmp5) { tmp14 = closure_7; num2 = 0; closure_7.current = 0; } if (!closure_4.current) { tmp16 = closure_2; if (closure_2.current !== tmp5) { tmp19 = null != tmp13.current && tmp13.current !== tmp5; if (tmp19) { tmp20 = waitForPause; tmp19 = waitForPause(tmp5); } if (!tmp19) { tmp21 = closure_9; if (null != closure_9.current) { tmp22 = globalThis; _clearTimeout = clearTimeout; clearTimeoutResult = clearTimeout(tmp21.current); tmp21.current = null; } flag3 = true; tmp15.current = true; tmp13.current = tmp5; tmp24 = closure_0; tmp25 = closure_2; obj = closure_0(closure_2[7]); obj1 = { orderId: null, giftInfo: null, expectedRevision: null }; obj1.orderId = id; obj4 = { recipient_id: null, gift_style: null, emoji_id: null, emoji_name: null, sound_id: null, reward_sku_ids: null, custom_message_contents: null }; ({ recipient_id: obj3.recipient_id, gift_style: obj3.gift_style, emoji_id: obj3.emoji_id, emoji_name: obj3.emoji_name, sound_id: obj3.sound_id, reward_sku_ids: obj3.reward_sku_ids, custom_message: obj3.custom_message_contents } = tmp5); obj1.giftInfo = obj4; obj1.expectedRevision = tmp8.current; updateOrderResult = obj.updateOrder(obj1); nextPromise = updateOrderResult.then((current) => { if (logger.current === id) { const tmp5 = null == ref3.current || current > ref3.current; if (tmp5) { ref3.current = current; } ref.current = current; ref6.current = 0; if (closure_11 != null) { tmp9(tmp, current); } } }); catchPromise = nextPromise.catch((error) => { ref4.current = ref4.current + 1; const obj = { error, orderId: id }; logger.error("Failed to sync gift customization to order", obj); const obj2 = BillingUtils; const obj3 = { tags: { source: "useSyncGiftOptionsToOrder" }, extra: { orderId: id } }; const result = obj2.captureBillingException(error, obj3); }); cleanupPromise = catchPromise.finally(() => { ref3.current = false; if (ref.current !== ref2.current) { if (0 === ref4.current) { closure_1_10((arg0) => arg0 + 1); } else if (ref4.current < 3) { const _setTimeout = setTimeout; ref8.current = setTimeout(() => closure_1_10(() => { /* body not rendered: F157510 */ }), 500 * 2 ** (ref4.current - 1)); } else { resolveSyncs(false); } } else { resolveSyncs(true); } }); } } else { tmp17 = resolveSyncs; flag2 = true; tmp18 = resolveSyncs(true); } } } else { tmp2 = resolveSyncs; flag = true; tmp3 = resolveSyncs(true); } return; } } cResult[3] = current; cResult[4] = arg0; cResult[5] = resolveSyncs; cResult[6] = tmp7; cResult[7] = waitForPause; cResult[8] = E; tmp12 = E; }) : (function useSyncGiftOptionsToOrder(arg0, current) { let closure_0 = arg0; importDefault = current; dependencyMap = react.useRef(null); ref = react.useRef(null); react = react.useRef(false); ref2 = react.useRef(undefined); ref5 = react.useRef(null); ref6 = react.useRef(0); const ref7 = react.useRef(null); const ref8 = react.useRef(null); let tmp = ref(react.useState(0), 2); const tmp3 = tmp[1]; let closure_10 = tmp3; const first = tmp[0]; const tmp4 = ref2((setOrderRevision) => setOrderRevision.setOrderRevision); let closure_11 = tmp4; let tmp5 = useGiftOptionsSyncDebounceDefault(tmp3); const waitForPause = tmp5.waitForPause; const flush = tmp5.flush; const waitForSync = tmp5.waitForSync; const resolveSyncs = tmp5.resolveSyncs; const effect = react.useEffect(() => () => { if (null != ref.current) { const _clearTimeout = clearTimeout; clearTimeout(tmp.current); } }, []); const items = [arg0, current, first, resolveSyncs, tmp4, waitForPause]; const effect1 = react.useEffect(() => { let id; let logger; let obj5; const tmp = id; if (null != id) { let tmp8; id = tmp.id; let tmp5 = current; ref2.current = current; if (ref5.current !== id) { ref5.current = id; const tmp9 = ref4; ref4.current = tmp.revision; ref.current = null; ref7.current = null; ref4.current = 0; tmp8 = ref4; } else { tmp8 = tmp6; const tmp7 = null == ref4.current || tmp.revision > ref4.current; if (tmp7) { ref4.current = tmp.revision; tmp8 = tmp6; } } if (ref7.current !== tmp5) { ref4.current = 0; } if (!ref3.current) { if (ref.current !== tmp5) { const tmp19 = null != tmp13.current && tmp13.current !== tmp5 && waitForPause(tmp5); if (!tmp19) { if (null != ref8.current) { const _clearTimeout = clearTimeout; clearTimeout(ref8.current); ref8.current = null; } tmp15.current = true; ref7.current = tmp5; let obj = closure_0(ref[7]); let obj2 = { orderId: id, giftInfo: obj5, expectedRevision: tmp8.current }; obj5 = { recipient_id: null, gift_style: null, emoji_id: null, emoji_name: null, sound_id: null, reward_sku_ids: null, custom_message_contents: null }; ({ recipient_id: obj3.recipient_id, gift_style: obj3.gift_style, emoji_id: obj3.emoji_id, emoji_name: obj3.emoji_name, sound_id: obj3.sound_id, reward_sku_ids: obj3.reward_sku_ids, custom_message: obj3.custom_message_contents } = tmp5); const updateOrderResult = obj.updateOrder(obj2); const nextPromise = updateOrderResult.then((current) => { if (logger.current === id) { const tmp5 = null == ref3.current || current > ref3.current; if (tmp5) { ref3.current = current; } ref.current = current; ref6.current = 0; if (closure_11 != null) { tmp9(tmp, current); } } }); const catchPromise = nextPromise.catch((error) => { ref4.current = ref4.current + 1; const obj = { error, orderId: id }; logger.error("Failed to sync gift customization to order", obj); const obj2 = BillingUtils; const obj3 = { tags: { source: "useSyncGiftOptionsToOrder" }, extra: { orderId: id } }; const result = obj2.captureBillingException(error, obj3); }); catchPromise.finally(() => { ref3.current = false; if (ref.current !== ref2.current) { if (0 === ref4.current) { closure_1_10((arg0) => arg0 + 1); } else if (ref4.current < 3) { const _setTimeout = setTimeout; ref8.current = setTimeout(() => closure_1_10((arg0) => arg0 + 1), 500 * 2 ** (ref4.current - 1)); } else { resolveSyncs(false); } } else { resolveSyncs(true); } }); } } else { resolveSyncs(true); } } } else { resolveSyncs(true); } }, items); const items1 = [arg0, flush, waitForSync]; const awaitSync = react.useCallback(() => { if (null != closure_0) { if (ref.current !== ref2.current) { if (ref6.current >= 3) { tmp3.current = 0; } flush(tmp2.current); current = ref3.current; const tmp7 = waitForSync(); if (!current) { current = null != ref8.current; } if (!current) { closure_10((arg0) => arg0 + 1); } return tmp7; } } return Promise.resolve(true); }, items1); const items2 = [awaitSync]; return react.useMemo(() => ({ awaitSync }), items2); }); let result = size.fileFinishedImporting("modules/checkout/native/useSyncGiftOptionsToOrder.tsx"); export default tmp3;