/* Metro module 1371; source: modules/dismissible_content/DismissibleContentShownStateStore.tsx; dependencies: [6, 7, 15, 17, 18, 1372, 1373, 1374, 685, 1370, 690, 1375, 566, 694, 2] */ function _fun15762(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#15762, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:6, offset: 0x00e3f3ab, size: 627 bytes, params: 8, frame: 21 const env0_0 = require; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_3 = importDefault(6) /* metro dependency 6 */; const env0_4 = importDefault(7) /* metro dependency 7 */; const env0_5 = importDefault(15) /* metro dependency 15 */; const env0_6 = importDefault(17) /* metro dependency 17 */; const env0_7 = importDefault(18) /* metro dependency 18 */; const loginRequiredActionStore = importDefault(1372) /* metro dependency 1372: LoginRequiredActionStore */; const userRequiredActionStore = importDefault(1373) /* metro dependency 1373: UserRequiredActionStore */; const TaskRunner = (require(1374) /* metro dependency 1374: TaskRunner */).TaskRunner; let taskRunner = new TaskRunner(); let closure = initState; const env0_12 = (require(685) /* metro dependency 685 */).createWithEqualityFn(closure); const withoutContent = function(a0, a1) { if (a1 != null) { if (a1.content != null) { a0.currentlyShown.delete(a1.content); } if (a1.groupName != null) { a0.currentlyShownGroup.delete(a1.groupName); } if (a0.shownFatigableCandidate?.content === a1.content) { a0.shownFatigableCandidate = null; } } return a0; }; const withoutCandidate = function(a0, a1) { a0.candidates.delete(a1.content); return a0; }; const swapFatigableContent = function(a0, a1) { var withContentBinding = withContent; withoutContent(a0, a0.shownFatigableCandidate); withContentBinding(a0, a1); return a0; }; closure = function(a0) { var Date = global.Date; var value2 = new Date(); value2 = value2.getTime(); return a0.shownFatigableCandidate == null && value2 - a0.lastWinnerTime < 3600000; }; const closure2 = reset_15780; const Store = (importDefault(566) /* metro dependency 566: flux */).Store; _fun15783(Store).displayName = 'DismissibleContentShownStateStore'; taskRunner = new taskRunner(importDefault(694) /* metro dependency 694: Dispatcher */, {CONNECTION_OPEN: function() { reset_15780(); }, LOGOUT: function() { reset_15780(); }}); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/dismissible_content/DismissibleContentShownStateStore.tsx'); exports.default = useDismissibleContentShownStateStore; exports.isInCooldown = isInCooldown; exports.isStateInCooldown = closure; exports.addCandidateContent = addCandidateContent; exports.removeCandidateContent = removeCandidateContent; exports.getLastShownDismissibleContent = getLastShownDismissibleContent; exports.getCurrentFatigableWinner = getCurrentFatigableWinner; exports.isContentShown = isContentShown; exports.useIsContentShown = useIsContentShown; exports.useIsAnyContentShown = useIsAnyContentShown; exports.isAnyContentShown = isAnyContentShown; exports.getCurrentlyShownCounts = getCurrentlyShownCounts; exports.reset = closure2; exports.isPostConnectionOpen = isPostConnectionOpen; exports.dismissibleContentShownStateStore = taskRunner; } function _isNativeReflectConstruct_15763() { // fn#15763, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:168, offset: 0x00e3f61e, size: 94 bytes, params: 1, frame: 18 var Boolean; var prototype; var valueOf; var call; var Reflect; var construct; var closure; var value; var error; try { Boolean = global.Boolean; prototype = Boolean.prototype; valueOf = prototype.valueOf; call = valueOf.call; Reflect = global.Reflect; construct = Reflect.construct; Boolean = global.Boolean; closure = function() { }; value = Reflect.apply(construct, Reflect, [Boolean, [], closure]); value = Reflect.apply(call, valueOf, [value]); var result = !value; } catch (error) { } return (_isNativeReflectConstruct_15763_isNativeReflectConstruct = function() { return !!result; })(); } function initState() { // fn#15766, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:401, offset: 0x00e3f67c, size: 131 bytes, params: 1, frame: 11 const object2 = {'candidates': null, 'shownFatigableCandidate': null, 'prevFatigableCandidate': null}; const Map = global.Map; object2.candidates = new Map(); object2.recentlyShown = []; let Set = global.Set; object2.currentlyShown = new Set(); Set = global.Set; object2.currentlyShownGroup = new Set(); object2.lastWinnerTime = 0; object2.postConnectionOpen = false; return object2; } function cloneState(a0) { // fn#15767, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:650, offset: 0x00e3f6ff, size: 142 bytes, params: 2, frame: 15 const object2 = {}; copyDataProperties(object2, a0, undefined); const Map = global.Map; object2['candidates'] = new Map(a0.candidates); let Set = global.Set; object2['currentlyShown'] = new Set(a0.currentlyShown); Set = global.Set; object2['currentlyShownGroup'] = new Set(a0.currentlyShownGroup); return object2; } function withContent(a0, a1) { // fn#15769, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:1063, offset: 0x00e3f7fc, size: 289 bytes, params: 3, frame: 15 var currentlyShownGroup; var prevFatigableCandidate; var date; const env0_0 = a1; if (a1 != null) { var currentlyShown = a0.currentlyShown; var add = currentlyShown.add; var content = a1.content; Reflect.apply(add, currentlyShown, [content]); var value = a0.recentlyShown.filter(function(a0) { return a0 !== require.content; }); var unshift = value.unshift; content = a1.content; Reflect.apply(unshift, value, [content]); value.splice(5); a0.recentlyShown = value; if (a1.groupName != null) { currentlyShownGroup = a0.currentlyShownGroup; currentlyShownGroup.add(a1.groupName); } value = undefined; var CONTENT_TYPES_WITH_BYPASS_FATIGUE = (require(1370) /* metro dependency 1370: DismissibleContentFatigueConfig */).CONTENT_TYPES_WITH_BYPASS_FATIGUE; var has = CONTENT_TYPES_WITH_BYPASS_FATIGUE.has; content = a1.content; if (!Reflect.apply(has, CONTENT_TYPES_WITH_BYPASS_FATIGUE, [content])) { a0.shownFatigableCandidate = a1; prevFatigableCandidate = a0.prevFatigableCandidate; if ((prevFatigableCandidate == null ? value : prevFatigableCandidate.content) !== a1.content) { a0.prevFatigableCandidate = a1; date = new global.Date(); a0.lastWinnerTime = date.getTime(); } } if (a1.onAdded != null) { a1.onAdded(); } } return a0; } function withUpdateWinner(a0) { // fn#15773, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:1709, offset: 0x00e3f976, size: 292 bytes, params: 2, frame: 18 var r2; if (a0.candidates.size !== 0) { var Date = global.Date; var date = new Date(); date = date.getTime(); date = date - a0.lastWinnerTime > 300000; r2 = a0.prevFatigableCandidate != null && a0.candidates.has(a0.prevFatigableCandidate.content); r2 = r2 && a0.shownFatigableCandidate == null; if (r2) { if (date) { if (a0.shownFatigableCandidate == null) { if (!(env0_10.scheduled() || isStateInCooldown(a0))) { env0_10.schedule(_fun15774, 250); } } else if (date) { if (!(env0_10.scheduled() || isStateInCooldown(a0))) { env0_10.schedule(_fun15774, 250); } } } else { env0_10.unschedule(); swapFatigableContent(a0, a0.prevFatigableCandidate != null ? a0.candidates.get(a0.prevFatigableCandidate.content) : undefined); } } else if (a0.shownFatigableCandidate == null) { if (!(env0_10.scheduled() || isStateInCooldown(a0))) { env0_10.schedule(_fun15774, 250); } } else if (date) { if (!(env0_10.scheduled() || isStateInCooldown(a0))) { env0_10.schedule(_fun15774, 250); } } } return a0; } function reset_15780() { // fn#15780, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:2693, offset: 0x00e3fc3c, size: 59 bytes, params: 1, frame: 13 (require(690) /* metro dependency 690: ReactBatchUpdatesNative */).batchUpdates(_fun15781); env0_10.unschedule(); } function _fun15783(a0) { // fn#15783, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:2818, offset: 0x00e3fcab, size: 93 bytes, params: 2, frame: 16 const closure = DismissibleContentShownStateStore; env0_7(closure, a0); return env0_4(closure, [{key: 'initialize', value: function() { var env0_0 = this; this.waitFor(LoginRequiredActionStore, UserRequiredActionStore); this.syncWith([LoginRequiredActionStore, UserRequiredActionStore], _fun15786); }}, {key: 'setHasRequiredAction', value: function() { env1_13 = importDefault(dependencyMap[11])(LoginRequiredActionStore, UserRequiredActionStore); }}]); } function useDismissibleContentShownStateStore(a0, a1) { // fn#15790, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:3613, offset: 0x00e3fe0b, size: 23 bytes, params: 3, frame: 13 return env0_12(a0, a1); } function isInCooldown() { // fn#15791, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:3695, offset: 0x00e3fe22, size: 30 bytes, params: 1, frame: 11 return isStateInCooldown(env0_12.getState()); } function addCandidateContent(a0) { // fn#15792, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:3793, offset: 0x00e3fe40, size: 89 bytes, params: 2, frame: 15 const env0_0 = a0; const CONTENT_TYPES_WITH_BYPASS_FATIGUE = (require(1370) /* metro dependency 1370: DismissibleContentFatigueConfig */).CONTENT_TYPES_WITH_BYPASS_FATIGUE; const env0_1 = CONTENT_TYPES_WITH_BYPASS_FATIGUE.has(a0.content); (require(690) /* metro dependency 690: ReactBatchUpdatesNative */).batchUpdates(_fun15793); } function removeCandidateContent(a0, a1) { // fn#15795, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4053, offset: 0x00e3ff0d, size: 59 bytes, params: 3, frame: 12 const env0_0 = a0; const env0_1 = a1; (require(690) /* metro dependency 690: ReactBatchUpdatesNative */).batchUpdates(_fun15796); } function getLastShownDismissibleContent() { // fn#15798, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4273, offset: 0x00e3ffbd, size: 43 bytes, params: 1, frame: 10 const binding = env0_12; const getState = binding.getState; const property = Reflect.apply(getState, binding, []).recentlyShown[0]; const value = null; return value != property ? property : value; } function getCurrentFatigableWinner() { // fn#15799, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4368, offset: 0x00e3ffe8, size: 53 bytes, params: 1, frame: 11 const binding = env0_12; const getState = binding.getState; const shownFatigableCandidate = Reflect.apply(getState, binding, []).shownFatigableCandidate; const value = null; const content = value == shownFatigableCandidate ? undefined : shownFatigableCandidate.content; return value != content ? content : value; } function isContentShown(a0) { // fn#15800, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4488, offset: 0x00e4001d, size: 38 bytes, params: 2, frame: 11 const binding = env0_12; const getState = binding.getState; return Reflect.apply(getState, binding, []).currentlyShown.has(a0); } function useIsContentShown(a0) { // fn#15801, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4547, offset: 0x00e40043, size: 30 bytes, params: 2, frame: 11 const env0_0 = a0; return env0_12(_fun15802); } function useIsAnyContentShown(a0) { // fn#15803, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4606, offset: 0x00e4007d, size: 30 bytes, params: 2, frame: 11 const env0_0 = a0; return env0_12(function(a0) { return a0.some(_fun15805); }); } function isAnyContentShown(a0) { // fn#15806, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4675, offset: 0x00e400d9, size: 50 bytes, params: 2, frame: 12 const binding = env0_12; const getState = binding.getState; const env0_0 = Reflect.apply(getState, binding, []).currentlyShown; return a0.find(function(a0) { return currentlyShown.has(a0); }); } function getCurrentlyShownCounts() { // fn#15808, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4770, offset: 0x00e40121, size: 93 bytes, params: 1, frame: 14 const binding = env0_12; let getState = binding.getState; const currentlyShown = Reflect.apply(getState, binding, []).currentlyShown; const items2 = []; arraySpread(items2, currentlyShown, 0, items2); const length = items2.filter(function(a0) { var CONTENT_TYPES_WITH_BYPASS_FATIGUE = require(dependencyMap[9]).CONTENT_TYPES_WITH_BYPASS_FATIGUE; return !CONTENT_TYPES_WITH_BYPASS_FATIGUE.has(a0); }).length; getState = binding.getState; return [Reflect.apply(getState, binding, []).currentlyShown.size, length]; } function isPostConnectionOpen() { // fn#15810, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4967, offset: 0x00e401af, size: 25 bytes, params: 1, frame: 9 const binding = env0_12; const getState = binding.getState; return Reflect.apply(getState, binding, []).postConnectionOpen; } function _fun15774() { // fn#15774, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:2152, offset: 0x00e3fa9a, size: 45 bytes, params: 1, frame: 12 var environment; const value = environment.__proto__; (require(690) /* metro dependency 690: ReactBatchUpdatesNative */).batchUpdates(_fun15775); } function _fun15781() { // fn#15781, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:2721, offset: 0x00e3fc77, size: 29 bytes, params: 1, frame: 11 env1_12.setState(_fun15782); } function value_15785() { // fn#15785, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:3213, offset: 0x00e3fd79, size: 65 bytes, params: 1, frame: 15 this.waitFor(LoginRequiredActionStore, UserRequiredActionStore); this.syncWith([LoginRequiredActionStore, UserRequiredActionStore], _fun15786); } function _fun15793() { // fn#15793, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:3883, offset: 0x00e3fe99, size: 29 bytes, params: 1, frame: 11 env1_12.setState(_fun15794); } function _fun15796() { // fn#15796, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4084, offset: 0x00e3ff48, size: 29 bytes, params: 1, frame: 11 env1_12.setState(_fun15797); } function _fun15802({currentlyShown}) { // fn#15802, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4553, offset: 0x00e40061, size: 28 bytes, params: 2, frame: 11 return currentlyShown.has(env0_0); } function _fun15804(a0) { // fn#15804, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4612, offset: 0x00e4009b, size: 34 bytes, params: 2, frame: 11 return a0.some(_fun15805); } function _fun15775() { // fn#15775, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:2180, offset: 0x00e3fac7, size: 29 bytes, params: 1, frame: 11 env2_12.setState(function(a0) { var value2 = cloneState(a0); swapFatigableContent(value2, _fun15777(value2)); return value2; }); } function _fun15782() { // fn#15782, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:2738, offset: 0x00e3fc94, size: 23 bytes, params: 1, frame: 9 let value = environment.__proto__.__proto__; value = initState(); value.postConnectionOpen = true; return value; } function _fun15786() { // fn#15786, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:3263, offset: 0x00e3fdba, size: 21 bytes, params: 1, frame: 9 return env0_0.setHasRequiredAction(); } function _fun15794(a0) { // fn#15794, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:3900, offset: 0x00e3feb6, size: 87 bytes, params: 2, frame: 18 var value3; var withUpdateWinnerBinding; var binding; var candidates; const value2 = cloneState(a0); if (!env2_13) { value3 = environment.__proto__; if (env1_1) { withContent(value2, env1_0); } else { withUpdateWinnerBinding = withUpdateWinner; binding = env1_0; candidates = value2.candidates; candidates.set(binding.content, binding); withUpdateWinnerBinding(value2); } } return value2; } function _fun15797(a0) { // fn#15797, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4101, offset: 0x00e3ff65, size: 88 bytes, params: 2, frame: 16 var withoutContentBinding; var withoutCandidateBinding; var binding; var withUpdateWinnerBinding; const value2 = cloneState(a0); if (require) { withUpdateWinnerBinding = withUpdateWinner; withoutContentBinding = withoutContent; withoutCandidateBinding = withoutCandidate; binding = env1_0; withoutCandidateBinding(value2, binding); withoutContentBinding(value2, binding); withUpdateWinnerBinding(value2); } else { withoutContentBinding = withoutContent; withoutCandidateBinding = withoutCandidate; binding = env1_0; withoutCandidateBinding(value2, binding); withoutContentBinding(value2, binding); } return value2; } function _fun15805(a0) { // fn#15805, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:4623, offset: 0x00e400bd, size: 28 bytes, params: 2, frame: 11 return env0_0.currentlyShown.has(a0); } function _fun15776(a0) { // fn#15776, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:2197, offset: 0x00e3fae4, size: 41 bytes, params: 2, frame: 13 const value2 = cloneState(a0); swapFatigableContent(value2, _fun15777(value2)); return value2; } function _fun15777(a0) { // fn#15777, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:2252, offset: 0x00e3fb0d, size: 187 bytes, params: 2, frame: 17 const env0_0 = a0; let candidates = a0.candidates; const value = candidates.keys(); const items2 = []; arraySpread(items2, value, 0, undefined); const r3 = a0.prevFatigableCandidate !== null && a0.candidates.has(a0.prevFatigableCandidate.content) && a0.candidates.size > 1 ? items2.filter(_fun15778) : items2; candidates = a0.candidates; const get = candidates.get; const Math = global.Math; const floor = Math.floor; const Math2 = global.Math; return Reflect.apply(get, candidates, [r3[Reflect.apply(floor, Math, [Math2.random() * r3.length])]]); } function _fun15778(a0) { // fn#15778, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1498:2413, offset: 0x00e3fbc8, size: 38 bytes, params: 2, frame: 3 return a0 !== env0_0.prevFatigableCandidate?.content; }