/* Metro module 1482; source: modules/keyboard/native/KeyboardUIStore.native.tsx; dependencies: [1483, 1346, 1580, 587, 1583, 1584, 1585, 477, 1597, 628, 690, 1598, 629, 1599, 1847, 1848, 1586, 1481, 2] */ function _fun16964(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#16964, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:6, offset: 0x00e600ae, size: 522 bytes, params: 8, frame: 23 const env0_0 = require; const _arrayLikeToArray_16967 = function(a0, a1) { var r0; var r1; var r2; var value3; var length; var value5; var value = undefined; var value2 = value == null; reducibleJoin2: while (true) { if (value2) { r0 = value2; break reducibleJoin2; } value3 = value > a0.length; r0 = value3; break reducibleJoin2; } reducibleJoin4: while (true) { if (r0) { length = a0.length; r1 = length; break reducibleJoin4; } r1 = value; break reducibleJoin4; } value = (0, global.Array)(r1); var value4 = 0; if (value4 < r1) { r2 = value4; reducibleLoop5: while (true) { value[r2] = a0[r2]; value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1; if (value5 < r1) { r2 = value5; continue reducibleLoop5; } break reducibleLoop5; } } return value; }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_3 = (require(1483) /* metro dependency 1483: AppLauncherNativeConstants */).AppLauncherRouteName; const env0_4 = (require(1346) /* metro dependency 1346: ExpressionPickerConstants */).ExpressionPickerViewType; const env0_5 = (require(1580) /* metro dependency 1580: MediaKeyboardConstants */).MediaKeyboardTarget; let Set = global.Set; let set = new Set(); Set = global.Set; set = new Set(); set = require(477) /* metro dependency 477: PlatformUtils */; set = set.isAndroid(); const r12 = set ? 'keyboardDidShow' : 'keyboardWillShow'; set = require(477) /* metro dependency 477: PlatformUtils */; set = set.isAndroid(); const r10 = set ? 'keyboardDidHide' : 'keyboardWillHide'; set = require(629) /* metro dependency 629 */; set = set.create(function() { var object2 = {}; var createInitialEntryStateBinding = createInitialEntryState; object2.main = createInitialEntryStateBinding('main'); object2.share = createInitialEntryStateBinding('share'); return {byAppEntry: object2}; }); const KeyboardEvents = (require(1599) /* metro dependency 1599 */).KeyboardEvents; KeyboardEvents.addListener(r12, _fun16976); KeyboardEvents.addListener(r10, _fun16978); (importDefault(1586) /* metro dependency 1586: SafeAreaStoreNative */).subscribe(function() { updateKeyboardStoreState({}); }); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/keyboard/native/KeyboardUIStore.native.tsx'); exports.default = set; exports.setKeyboardType = setKeyboardType; exports.addKeyboardWillOpenChangedListener = addKeyboardWillOpenChangedListener; exports.addKeyboardTypeChangedListener = addKeyboardTypeChangedListener; } function _createForOfIteratorHelperLoose_16965(a0, a1) { // fn#16965, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:199, offset: 0x00e602b8, size: 370 bytes, params: 3, frame: 20 var r6; var r9; var r5; var value3; var regexp; const env0_0 = a0; const Symbol = global.Symbol; let value = typeof Symbol !== 'undefined'; let r1 = value && a0[global.Symbol.iterator]; r1 = !r1 ? a0['@@iterator'] : r1; if (r1) { value = r1.call(a0); return value.next.bind(value); } const Array = global.Array; if (Array.isArray(a0)) { if (r1) { } return _fun16966; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_16967(a0, value); r5 = value; } else { value3 = ({}).toString.call(a0).slice(8, -1); r6 = value3 === 'Object' && a0.constructor; r9 = r6 ? a0.constructor.name : value3; if (r9 === 'Map') { r6 = global.Array.from(a0); } else if (r9 === 'Set') { r6 = global.Array.from(a0); } else if (r9 === 'Arguments') { value = _arrayLikeToArray_16967(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_16967(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun16966; } const TypeError = global.TypeError; throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); } function getCustomKeyboardHeight(a0, a1, a2, a3) { // fn#16968, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:1158, offset: 0x00e6042a, size: 312 bytes, params: 5, frame: 20 var bottom; var value5; var value; const Storage = (require(587) /* metro dependency 587: Storage */).Storage; const value2 = 253; const r1 = Storage.get(env0_6, value2) ?? value2; const KeyboardTypes = (require(1583) /* metro dependency 1583: KeyboardTypes */).KeyboardTypes; const SYSTEM = KeyboardTypes.SYSTEM; if (a1 === SYSTEM) { var value4 = 0; if (value4 === a0) { if (a2) { value = require(1585) /* metro dependency 1585: useSafeAreaInsetsNative */; bottom = value.getSafeAreaInsets(a3).bottom; } else { bottom = 0; } return r1 - bottom; } var moduleValue = require(1584) /* metro dependency 1584: ChatInputFocused */; var getIsAnyChatInputFocused = moduleValue.getIsAnyChatInputFocused; if (Reflect.apply(getIsAnyChatInputFocused, moduleValue, [])) { value5 = global.Math.max(a0, 200); if (value5 !== r1) { Storage.set(env0_6, value5); } if (a2) { value = require(1585) /* metro dependency 1585: useSafeAreaInsetsNative */; bottom = value.getSafeAreaInsets(a3).bottom; } else { bottom = value4; } return value5 - bottom; } } if (a2) { value = require(1585) /* metro dependency 1585: useSafeAreaInsetsNative */; bottom = value.getSafeAreaInsets(a3).bottom; } else { bottom = 0; } return r1 - bottom; } function getSystemKeyboardHeight({keyboardHeight, excludeSafeAreaInsets, appEntryKey}) { // fn#16969, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:1617, offset: 0x00e60562, size: 146 bytes, params: 2, frame: 19 var bottom; var r0; var value2; var value; const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */; if (platformUtilsModule.isAndroid()) { value = importDefault(1597) /* metro dependency 1597: NativeSafeAreaInsetsModule */; value = value.getImeInsets(excludeSafeAreaInsets, appEntryKey); r0 = value; } else { value2 = 0; if (value2 === keyboardHeight) { r0 = value2; } else { if (excludeSafeAreaInsets) { value = require(1585) /* metro dependency 1585: useSafeAreaInsetsNative */; bottom = value.getSafeAreaInsets(appEntryKey).bottom; } else { bottom = value2; } value = keyboardHeight - bottom; r0 = value; } } return r0; } function computeEntryState(a0, a1, a2) { // fn#16970, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:1815, offset: 0x00e605f4, size: 718 bytes, params: 4, frame: 31 var object4; var systemKeyboardOpen; var r6; var object3; const value = a0; let keyboardDuration = a1.keyboardDuration; keyboardDuration = keyboardDuration ?? value.keyboardDuration; let getSystemKeyboardHeightBinding = getSystemKeyboardHeight; let keyboardHeight = a1.keyboardHeight; keyboardHeight = keyboardHeight ?? value.keyboardHeight; const value3 = undefined; const systemKeyboardHeightBinding = getSystemKeyboardHeightBinding({keyboardHeight: keyboardHeight, excludeSafeAreaInsets: false, appEntryKey: a2}); getSystemKeyboardHeightBinding = getSystemKeyboardHeight; object4 = {}; keyboardHeight = a1.keyboardHeight; keyboardHeight = keyboardHeight ?? value.keyboardHeight; object4.keyboardHeight = keyboardHeight; object4.excludeSafeAreaInsets = true; object4.appEntryKey = a2; const systemKeyboardHeightBinding2 = getSystemKeyboardHeightBinding(object4); let keyboardType = a1.keyboardType; const r5 = (keyboardType == null ? value3 : keyboardType.type) ?? value.keyboardType; const r4 = r5 !== value.keyboardType ? value.keyboardType : value.keyboardTypePrevious; const getCustomKeyboardHeightBinding = getCustomKeyboardHeight; const customKeyboardHeightBinding = getCustomKeyboardHeightBinding(systemKeyboardHeightBinding, r5, false, a2); const customKeyboardHeightBinding2 = getCustomKeyboardHeightBinding(systemKeyboardHeightBinding, r5, true, a2); let keyboardContexts = value.keyboardContexts; const property = keyboardContexts[r5]; keyboardType = a1.keyboardType; const r13 = (keyboardType == null ? value3 : keyboardType.context) ?? property; let r10 = typeof property !== 'object' ? property !== r13 : typeof r13 === 'object' ? !(importDefault(628) /* metro dependency 628: shallowEqual */)(property, r13) : property !== r13; const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */; if (platformUtilsModule.isAndroid()) { r6 = systemKeyboardHeightBinding > 0; } else { systemKeyboardOpen = a1.systemKeyboardOpen; systemKeyboardOpen = systemKeyboardOpen ?? value.systemKeyboardOpen; r6 = systemKeyboardOpen; } keyboardContexts = value.keyboardContexts; const KeyboardTypes = (require(1583) /* metro dependency 1583: KeyboardTypes */).KeyboardTypes; let SYSTEM = KeyboardTypes.SYSTEM; if (keyboardContexts[SYSTEM].keyboardWillOpen) { if (a1.systemKeyboardOpen != null) { object4 = {}; keyboardContexts = value.keyboardContexts; copyDataProperties(object4, keyboardContexts, true); SYSTEM = KeyboardTypes.SYSTEM; object3 = {}; keyboardContexts = value.keyboardContexts; copyDataProperties(object3, keyboardContexts[KeyboardTypes.SYSTEM], true); object3['keyboardWillOpen'] = false; object4[SYSTEM] = object3; r10 = object4; } else { keyboardContexts = value.keyboardContexts; if (r10) { object4 = {}; copyDataProperties(object4, keyboardContexts, true); object4[r5] = r13; r10 = object4; } else { r10 = keyboardContexts; } } } else { keyboardContexts = value.keyboardContexts; if (r10) { object4 = {}; copyDataProperties(object4, keyboardContexts, true); object4[r5] = r13; r10 = object4; } else { r10 = keyboardContexts; } } return value.keyboardDuration !== keyboardDuration ? {keyboardContexts: r10, keyboardDuration: keyboardDuration, keyboardHeight: systemKeyboardHeightBinding, keyboardHeightExcludingSafeAreaInsets: systemKeyboardHeightBinding2, systemKeyboardOpen: r6, keyboardType: r5, keyboardTypePrevious: r4, customKeyboardHeight: customKeyboardHeightBinding, customKeyboardHeightExcludingSafeAreaInsets: customKeyboardHeightBinding2} : (importDefault(628) /* metro dependency 628: shallowEqual */)(value.keyboardContexts, r10) ? value.keyboardHeight !== systemKeyboardHeightBinding || value.keyboardHeightExcludingSafeAreaInsets !== systemKeyboardHeightBinding2 || (value.keyboardType !== r5 || value.customKeyboardHeight !== customKeyboardHeightBinding) || value.customKeyboardHeightExcludingSafeAreaInsets !== customKeyboardHeightBinding2 ? {keyboardContexts: r10, keyboardDuration: keyboardDuration, keyboardHeight: systemKeyboardHeightBinding, keyboardHeightExcludingSafeAreaInsets: systemKeyboardHeightBinding2, systemKeyboardOpen: r6, keyboardType: r5, keyboardTypePrevious: r4, customKeyboardHeight: customKeyboardHeightBinding, customKeyboardHeightExcludingSafeAreaInsets: customKeyboardHeightBinding2} : value.systemKeyboardOpen === r6 ? value : {keyboardContexts: r10, keyboardDuration: keyboardDuration, keyboardHeight: systemKeyboardHeightBinding, keyboardHeightExcludingSafeAreaInsets: systemKeyboardHeightBinding2, systemKeyboardOpen: r6, keyboardType: r5, keyboardTypePrevious: r4, customKeyboardHeight: customKeyboardHeightBinding, customKeyboardHeightExcludingSafeAreaInsets: customKeyboardHeightBinding2} : {keyboardContexts: r10, keyboardDuration: keyboardDuration, keyboardHeight: systemKeyboardHeightBinding, keyboardHeightExcludingSafeAreaInsets: systemKeyboardHeightBinding2, systemKeyboardOpen: r6, keyboardType: r5, keyboardTypePrevious: r4, customKeyboardHeight: customKeyboardHeightBinding, customKeyboardHeightExcludingSafeAreaInsets: customKeyboardHeightBinding2}; } function updateKeyboardStoreState(a0, a1) { // fn#16971, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:3366, offset: 0x00e608c2, size: 59 bytes, params: 3, frame: 12 const env0_0 = a0; const env0_1 = a1; (require(690) /* metro dependency 690: ReactBatchUpdatesNative */).batchUpdates(_fun16972); } function createInitialEntryState(a0) { // fn#16974, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:3684, offset: 0x00e609df, size: 391 bytes, params: 2, frame: 24 const object2 = {}; const getCustomKeyboardHeightBinding = getCustomKeyboardHeight; const KeyboardTypes = (require(1583) /* metro dependency 1583: KeyboardTypes */).KeyboardTypes; let SYSTEM = KeyboardTypes.SYSTEM; object2.customKeyboardHeight = getCustomKeyboardHeightBinding(0, SYSTEM, false, a0); SYSTEM = KeyboardTypes.SYSTEM; object2.customKeyboardHeightExcludingSafeAreaInsets = getCustomKeyboardHeightBinding(0, SYSTEM, true, a0); SYSTEM = KeyboardTypes.SYSTEM; const EXPRESSION = KeyboardTypes.EXPRESSION; const EMOJI = ExpressionPickerViewType.EMOJI; const MEDIA = KeyboardTypes.MEDIA; const CHAT = MediaKeyboardTarget.CHAT; const APP_LAUNCHER = KeyboardTypes.APP_LAUNCHER; const HOME = AppLauncherRouteName.HOME; object2.keyboardContexts = {[SYSTEM]: {keyboardWillOpen: false}, [EXPRESSION]: EMOJI, [MEDIA]: {target: CHAT}, [APP_LAUNCHER]: {initialRouteName: HOME}}; object2.keyboardDuration = 0; const getSystemKeyboardHeightBinding = getSystemKeyboardHeight; object2.keyboardHeight = getSystemKeyboardHeightBinding({'keyboardHeight': 0, 'excludeSafeAreaInsets': false, appEntryKey: a0}); object2.keyboardHeightExcludingSafeAreaInsets = getSystemKeyboardHeightBinding({'keyboardHeight': 0, 'excludeSafeAreaInsets': true, appEntryKey: a0}); object2.systemKeyboardOpen = false; SYSTEM = KeyboardTypes.SYSTEM; object2.keyboardType = SYSTEM; SYSTEM = KeyboardTypes.SYSTEM; object2.keyboardTypePrevious = SYSTEM; return object2; } function _fun16976({duration, height}) { // fn#16976, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:4662, offset: 0x00e60b96, size: 134 bytes, params: 2, frame: 17 (importDefault(1847) /* metro dependency 1847: KeyboardStateDebugging */).reactNativeKeyboardDidShow(height, 'KeyboardUIStore'); updateKeyboardStoreState({keyboardHeight: height, keyboardDuration: duration, systemKeyboardOpen: true}); (require(1848) /* metro dependency 1848: KeyboardManagerUtils */).onKeyboardChanged(true); env0_8.forEach(function(a0) { return a0(false); }); } function _fun16978() { // fn#16978, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:4928, offset: 0x00e60c2a, size: 113 bytes, params: 1, frame: 14 (importDefault(1847) /* metro dependency 1847: KeyboardStateDebugging */).reactNativeKeyboardDidHide('KeyboardUIStore'); updateKeyboardStoreState({'keyboardHeight': 0, 'systemKeyboardOpen': false}); (require(1848) /* metro dependency 1848: KeyboardManagerUtils */).onKeyboardChanged(false); env0_8.forEach(function(a0) { return a0(false); }); } function setKeyboardType(a0) { // fn#16981, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:5295, offset: 0x00e60cad, size: 111 bytes, params: 2, frame: 17 const value = a1; const env0_0 = a0; const r3 = value !== undefined ? value : (require(1481) /* metro dependency 1481: AppEntryKeyContext */).DEFAULT_APP_ENTRY_KEY; env0_7.forEach(_fun16982); env0_8.forEach(_fun16983); updateKeyboardStoreState({keyboardType: a0}, r3); } function addKeyboardWillOpenChangedListener(a0) { // fn#16984, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:5593, offset: 0x00e60d83, size: 33 bytes, params: 2, frame: 12 const env0_0 = a0; env0_8.add(a0); return _fun16985; } function addKeyboardTypeChangedListener(a0) { // fn#16986, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:5707, offset: 0x00e60dbe, size: 33 bytes, params: 2, frame: 12 const env0_0 = a0; env0_7.add(a0); return _fun16987; } function _fun16972() { // fn#16972, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:3429, offset: 0x00e608fd, size: 27 bytes, params: 1, frame: 11 return env1_9.setState(_fun16973); } function _fun16983(a0) { // fn#16983, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:5391, offset: 0x00e60d1c, size: 103 bytes, params: 2, frame: 15 const type = env0_0.type; const value3 = undefined; const KeyboardTypes = (require(1583) /* metro dependency 1583: KeyboardTypes */).KeyboardTypes; const SYSTEM = KeyboardTypes.SYSTEM; return a0(type === SYSTEM && (env0_0.context == null ? value3 : env0_0.context.keyboardWillOpen) === true, env0_1); } function _fun16985() { // fn#16985, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:5656, offset: 0x00e60da4, size: 26 bytes, params: 1, frame: 11 return env1_8.delete(env0_0); } function _fun16987() { // fn#16987, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:5766, offset: 0x00e60ddf, size: 26 bytes, params: 1, frame: 11 return env1_7.delete(env0_0); } function _fun16973(a0) { // fn#16973, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1609:3445, offset: 0x00e60918, size: 199 bytes, params: 2, frame: 23 var r4; var r9; var r2; var object2; var value7; var property; var entryState; var value8; const value = a0; let r3 = require != null ? [require] : (require(1598) /* metro dependency 1598: AppEntryKey */).APP_ENTRY_KEYS; const byAppEntry = value.byAppEntry; const value5 = _createForOfIteratorHelperLoose_16965(r3); const value6 = value5(); let done = value6.done; if (done) { r2 = byAppEntry; } else { r3 = byAppEntry; r4 = value6; while (true) { value7 = r4.value; property = r3[value7]; entryState = computeEntryState(property, env1_0, value7); if (property === entryState) { r9 = r3; } else { object2 = {}; copyDataProperties(object2, r3, undefined); object2[value7] = entryState; r9 = object2; } value8 = value5(); done = value8.done; if (done) { r2 = r9; break; } r3 = r9; r4 = value8; continue; } } return r2 === value.byAppEntry ? value : {byAppEntry: r2}; }